Fetch EVM block headers in parallel for faster sync#668
Open
Fetch EVM block headers in parallel for faster sync#668
Conversation
The EVM fetcher's readData loop was fetching each block header one at a time via individual eth_getBlockByNumber RPC calls. With stepSize=9 this meant 9 sequential round-trips per batch, making the fetcher the bottleneck for the entire sync pipeline (~1.5 blocks/s). Switch from genOnDemandPageRequests (lazy, sequential) to genImmediatePageRequests (eager, parallel via Promise.all). This fires all getBlock calls concurrently, reducing per-batch latency from ~N×RTT to ~1×RTT. Benchmarked with Arbitrum mainnet + Midnight mainnet + real PostgreSQL: stepSize=9: 1.48 → 6.37 blocks/s (4.3× faster) stepSize=36: 1.67 → 22.5 blocks/s (13.5× faster) Also adds: - Timestamp to finalized-block log line for easier profiling - e2e/performance/ benchmark (NTP + Arbitrum + Midnight, PGLite or real PG) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
readDatawas callingeth_getBlockByNumbersequentially for each block in the step range. WithstepSize=9, that's 9 serial RPC round-trips per batch, making the fetcher the bottleneck for the entire sync pipeline.genOnDemandPageRequests(lazy/sequential) togenImmediatePageRequests(eager/parallel viaPromise.all), so all block headers in the range are fetched concurrently.e2e/performance/benchmark that syncs NTP + Arbitrum + Midnight (PGLite or real PostgreSQL).Benchmark results (Arbitrum mainnet + Midnight mainnet, real PostgreSQL)
Test plan
e2e/performance/perf-test.tswith PGLite (in-memory) — all 120 blocks finalize in <0.5sstepSize=9stepSizenow actually scales throughput (previously flat due to sequential fetch)🤖 Generated with Claude Code