Skip to content

perf: hash tx effects tree nodes synchronously - #269

Draft
vezenovm wants to merge 1 commit into
mainfrom
mv/sync-tx-effects-tree-hash
Draft

vezenovm wants to merge 1 commit into
mainfrom
mv/sync-tx-effects-tree-hash

Conversation

@vezenovm

Copy link
Copy Markdown
Contributor

Summary

Switches only txEffectsTreeNodeHash to the existing synchronous Poseidon helper through the initialized crypto/sync entrypoint.

  • preserves the Promise-returning hasher interface, TX_EFFECTS_TREE domain separator, input serialization, and output
  • leaves effect-category and tx-effect leaf hashing asynchronous
  • also accelerates membership construction and verification, which share this internal-node hasher
  • keeps the existing backend policy: native shared memory where available, synchronous WASM fallback elsewhere
  • adds no transport setting, bb endpoint, batching, or general tree refactor

Benchmark methodology and the reusable harness are in #260. The harness files and raw output are intentionally absent from this PR.

Same-revision transport benchmark

Measured on this PR's origin/main base and toolchain in two focused runs: old production UDS hashing versus UDS leaves with the new sync-SHM internal hasher. Each scenario reports the median of 15 samples after three warmups. Times are milliseconds per complete operation.

Profile Txs Before After Change
Sparse 1 0.135 0.135 inconclusive
Sparse 3 0.292 0.271 −7.3%
Sparse 16 1.510 1.317 −12.8%
Sparse 64 6.116 5.395 −11.8%
Small categories 1 0.189 0.189 inconclusive
Small categories 3 0.433 0.429 inconclusive
Small categories 16 2.319 2.193 −5.4%
Small categories 64 10.630 9.833 −7.5%
Log-heavy 1 8.784 8.531 −2.9%
Log-heavy 3 26.400 25.316 −4.1%
Log-heavy 16 141.561 138.267 −2.3%
Log-heavy 64 574.766 575.820 inconclusive

The earlier 5–8% expectation was a hypothesis. The measured complete-commitment result is workload- and tree-size-dependent: 7.5% for the 64-transaction small-category case, 11.8% for sparse/64, and no detectable change when large leaf hashes dominate.

Internal tree and membership

These 64-leaf cases use precomputed leaves, isolating the shared internal-node path.

Workload Before ms After ms Change
Internal tree 1.839 0.947 −48.5%
Membership construction 1.937 1.050 −45.8%
Membership verification 0.178 0.092 −48.6%

Checkpoint benchmark

Before and after runs used the same current-main revision and toolchain. Each case has three warmups and 15 measured samples; every sample creates a fresh builder and world-state fork. Mixed direction and small differences make these checkpoint-level results inconclusive.

Profile Txs buildHeaderAndBody before after Total before after
Worst-case 4 27.677 25.899 40.441 38.243
Worst-case 8 53.111 51.788 76.758 75.188
Worst-case 16 108.255 105.194 155.529 151.816
Class-log-heavy 4 57.112 59.838 82.731 87.643
Class-log-heavy 8 114.993 112.686 165.362 164.033

Responsiveness

Median of three saturated probe rounds with four concurrent 64-transaction small-category commitment loops. This is synthetic saturation, not a node RPC latency prediction.

Metric Before After
Complete ops/s 96.8 93.1
Worker ping p50 0.05 ms 0.05 ms
Worker ping p95 13.66 ms 5.35 ms
Worker ping max 16.18 ms 12.84 ms
Main timer max delay 11.94 ms 10.19 ms

Throughput and latency differences in this probe are within run-to-run noise; importantly, selectively synchronous internal hashing does not reproduce the roughly one-second starvation seen when all category and leaf hashing is synchronous.

Validation

  • ./bootstrap.sh from yarn-project passed after updating to current main.
  • Full TypeScript build passed.
  • Repository-wide format and lint checks passed.
  • Body and tx-effect membership suites passed before and after: 18 tests covering empty, single-leaf, balanced, unbalanced, and invalid-witness cases.
  • The same 18 tests passed with BB_BINARY_PATH forced to a nonexistent path, exercising the synchronous WASM fallback.
  • Focused before/after transport benchmark runs and both 15-sample checkpoint runs passed.

Raw samples remain in ignored local output. Blob accumulator batching, block-header trees, and the full sequencer benchmark are out of scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant