Skip to content

Streaming events#1808

Merged
v0d1ch merged 13 commits into
masterfrom
streaming-events
Feb 6, 2025
Merged

Streaming events#1808
v0d1ch merged 13 commits into
masterfrom
streaming-events

Conversation

@ch1bo

@ch1bo ch1bo commented Jan 28, 2025

Copy link
Copy Markdown
Member

Changes I made originally for the hydra-doom project to load all events in state (12GB+ in that use case) with constant memory using conduit streams.

There is a big TODO on this: IOSim s does not have a MonadUnliftIO instance and its not impossible to have one. We need to change the interface further such that we can compose createHydraNode and hydrate functions with in-memory EventSource variants.

A bit of a wart: The mkProjection does run the conduit for each projection, instead we should run the conduit once and build the projected in-memory read/query model once.

Also, the change here is not constant-memory as the ServerOutput history is still kept fully in memory. But this is a different story and should be covered by #1618


  • CHANGELOG updated or not needed
  • Documentation updated or not needed
  • Haddocks updated or not needed
  • No new TODOs introduced or explained herafter

@ch1bo ch1bo requested a review from a team January 28, 2025 14:31
@ch1bo ch1bo force-pushed the streaming-events branch 4 times, most recently from f3762c6 to 53a0ff3 Compare January 28, 2025 16:10
@github-actions

github-actions Bot commented Jan 28, 2025

Copy link
Copy Markdown

Transaction cost differences

No cost or size differences found

@github-actions

github-actions Bot commented Jan 28, 2025

Copy link
Copy Markdown

Transaction costs

Sizes and execution budgets for Hydra protocol transactions. Note that unlisted parameters are currently using arbitrary values and results are not fully deterministic and comparable to previous runs.

Metadata
Generated at 2025-02-06 15:06:37.89236239 UTC
Max. memory units 14000000
Max. CPU units 10000000000
Max. tx size (kB) 16384

Script summary

Name Hash Size (Bytes)
νInitial c8a101a5c8ac4816b0dceb59ce31fc2258e387de828f02961d2f2045 2652
νCommit 61458bc2f297fff3cc5df6ac7ab57cefd87763b0b7bd722146a1035c 685
νHead 0e35115a2c7c13c68ecd8d74e4987c04d4539e337643be20bb3274bd 14756
μHead 57166715eadb8d3135964325c016eea546c21e1c0aae974ca67df9a5* 5541
νDeposit ae01dade3a9c346d5c93ae3ce339412b90a0b8f83f94ec6baa24e30c 1102
  • The minting policy hash is only usable for comparison. As the script is parameterized, the actual script is unique per head.

Init transaction costs

Parties Tx size % max Mem % max CPU Min fee ₳
1 6093 10.80 3.35 0.53
2 6294 13.04 4.04 0.56
3 6495 15.71 4.88 0.60
5 6895 20.07 6.21 0.66
10 7904 31.40 9.68 0.82
40 13935 98.61 30.29 1.78

Commit transaction costs

This uses ada-only outputs for better comparability.

UTxO Tx size % max Mem % max CPU Min fee ₳
1 561 2.44 1.16 0.20
2 739 3.38 1.73 0.22
3 914 4.36 2.33 0.24
5 1280 6.41 3.60 0.28
10 2179 12.13 7.25 0.40
54 10062 98.61 68.52 1.88

CollectCom transaction costs

Parties UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
1 56 528 26.44 7.58 0.44
2 114 636 35.86 10.21 0.54
3 171 751 43.49 12.44 0.62
4 226 862 56.48 15.93 0.76
5 282 969 65.59 18.50 0.86
6 340 1081 69.38 19.76 0.90
7 394 1192 84.78 24.00 1.06

Cost of Increment Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 1822 25.42 8.32 0.50
2 1988 27.70 9.79 0.53
3 2084 28.69 10.66 0.55
5 2411 33.14 13.44 0.62
10 3229 45.45 20.82 0.81
37 7127 95.30 54.73 1.63

Cost of Decrement Transaction

Parties Tx size % max Mem % max CPU Min fee ₳
1 600 23.99 7.61 0.43
2 696 23.76 8.19 0.43
3 867 26.49 9.61 0.47
5 1135 29.63 11.81 0.52
10 1937 41.22 18.34 0.70
37 5826 93.14 50.65 1.52

Close transaction costs

Parties Tx size % max Mem % max CPU Min fee ₳
1 700 29.15 9.21 0.48
2 771 32.89 10.93 0.53
3 930 34.75 12.17 0.56
5 1259 37.18 14.41 0.61
10 2061 50.83 22.12 0.81
32 5133 95.82 50.81 1.52

Contest transaction costs

Parties Tx size % max Mem % max CPU Min fee ₳
1 629 35.29 10.70 0.54
2 806 38.19 12.33 0.58
3 984 41.07 13.96 0.63
5 1278 45.29 16.57 0.69
10 2095 58.47 24.19 0.89
26 4478 96.26 46.73 1.46

Abort transaction costs

There is some variation due to the random mixture of initial and already committed outputs.

Parties Tx size % max Mem % max CPU Min fee ₳
1 5986 28.33 9.33 0.71
2 6091 37.32 12.30 0.81
3 6248 46.92 15.46 0.92
4 6454 57.76 19.17 1.04
5 6580 67.85 22.42 1.15
6 6709 73.91 24.44 1.22
7 6696 82.65 27.25 1.31
8 6826 91.19 30.10 1.40

FanOut transaction costs

Involves spending head output and burning head tokens. Uses ada-only UTXO for better comparability.

Parties UTxO UTxO (bytes) Tx size % max Mem % max CPU Min fee ₳
10 0 0 6091 19.86 6.53 0.63
10 1 57 6126 21.33 7.13 0.64
10 5 284 6261 30.31 10.59 0.75
10 10 570 6431 40.96 14.72 0.87
10 20 1140 6771 62.72 23.14 1.12
10 30 1709 7112 84.42 31.54 1.37
10 37 2104 7347 98.48 37.03 1.54

End-to-end benchmark results

This page is intended to collect the latest end-to-end benchmark results produced by Hydra's continuous integration (CI) system from the latest master code.

Please note that these results are approximate as they are currently produced from limited cloud VMs and not controlled hardware. Rather than focusing on the absolute results, the emphasis should be on relative results, such as how the timings for a scenario evolve as the code changes.

Generated at 2025-02-06 15:09:57.761532918 UTC

Baseline Scenario

Number of nodes 1
Number of txs 300
Avg. Confirmation Time (ms) 5.192261353
P99 14.733979309999985ms
P95 7.186082700000006ms
P50 4.7220705ms
Number of Invalid txs 0

| Memory data |

2025-02-06 15:08:32.847071201 UTC
Used: 939M, Free: 6116M
2025-02-06 15:08:37.847023361 UTC
Used: 1047M, Free: 5916M
2025-02-06 15:08:42.846994108 UTC
Used: 1048M, Free: 5914M
2025-02-06 15:08:47.846902344 UTC
Used: 1055M, Free: 5906M
2025-02-06 15:08:52.846881424 UTC
Used: 1055M, Free: 5906M
2025-02-06 15:08:57.846892693 UTC
Used: 1060M, Free: 5901M

Three local nodes

Number of nodes 3
Number of txs 900
Avg. Confirmation Time (ms) 26.191480528
P99 47.3472604199996ms
P95 36.33433719999999ms
P50 24.0095065ms
Number of Invalid txs 0

| Memory data |

2025-02-06 15:09:10.809246665 UTC
Used: 995M, Free: 5978M
2025-02-06 15:09:15.809568831 UTC
Used: 1170M, Free: 5802M
2025-02-06 15:09:20.809472768 UTC
Used: 1187M, Free: 5783M
2025-02-06 15:09:25.809595253 UTC
Used: 1195M, Free: 5775M
2025-02-06 15:09:30.810608024 UTC
Used: 1232M, Free: 5673M
2025-02-06 15:09:35.809475515 UTC
Used: 1270M, Free: 5552M
2025-02-06 15:09:40.809429508 UTC
Used: 1283M, Free: 5538M
2025-02-06 15:09:45.80958518 UTC
Used: 1283M, Free: 5538M
2025-02-06 15:09:50.809549363 UTC
Used: 1295M, Free: 5524M
2025-02-06 15:09:55.809471116 UTC
Used: 1298M, Free: 5521M

@noonio noonio linked an issue Feb 4, 2025 that may be closed by this pull request
4 tasks
@ch1bo ch1bo assigned v0d1ch and ch1bo Feb 4, 2025
@ch1bo ch1bo requested a review from v0d1ch February 4, 2025 19:09
@v0d1ch v0d1ch force-pushed the streaming-events branch 4 times, most recently from ba89a14 to 4dda719 Compare February 6, 2025 11:24
Comment thread hydra-node/src/Hydra/API/Server.hs Outdated
@v0d1ch v0d1ch force-pushed the streaming-events branch 3 times, most recently from 22011b5 to 7da0e32 Compare February 6, 2025 12:40

@ch1bo ch1bo left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't merge like this.

Comment thread hydra-node/src/Hydra/API/Server.hs Outdated
@v0d1ch v0d1ch force-pushed the streaming-events branch 2 times, most recently from df30737 to 79e4471 Compare February 6, 2025 13:54
@github-actions

github-actions Bot commented Feb 6, 2025

Copy link
Copy Markdown

Test Results

  5 files  ±0  165 suites  ±0   34m 2s ⏱️ + 2m 44s
564 tests +1  562 ✅ +1  2 💤 ±0  0 ❌ ±0 
566 runs  +1  564 ✅ +1  2 💤 ±0  0 ❌ ±0 

Results for commit 30c01ad. ± Comparison against base commit 18ea31d.

♻️ This comment has been updated with latest results.

ch1bo added 4 commits February 6, 2025 15:16
This requires MonadUnliftIO on hydrate and createNode functions to run
the conduits.

However, the io-sim tests' IOSim s monad does not have an instance!
This re-loading the same server outputs 3 times though.
ch1bo and others added 8 commits February 6, 2025 15:16
Instead of running the conduits (which would require runResourceT), we
just construct the 'DraftHydraNode' directly.
Mistakenly used fuseBoth instead of zipSinks
This avoids redundant definitions at the cost of not having all
functions bound in the handle.
Signed-off-by: Sasha Bogicevic <sasha.bogicevic@iohk.io>
Signed-off-by: Sasha Bogicevic <sasha.bogicevic@iohk.io>
Signed-off-by: Sasha Bogicevic <sasha.bogicevic@iohk.io>
Signed-off-by: Sasha Bogicevic <sasha.bogicevic@iohk.io>
Signed-off-by: Sasha Bogicevic <sasha.bogicevic@iohk.io>
Signed-off-by: Sasha Bogicevic <sasha.bogicevic@iohk.io>
@v0d1ch v0d1ch added this pull request to the merge queue Feb 6, 2025
Merged via the queue into master with commit f971747 Feb 6, 2025
@v0d1ch v0d1ch deleted the streaming-events branch February 6, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Constant memory API server history using StateEvents

3 participants