perf(l1): run batch block execution on spawn_blocking - #7117
Open
NikhilSharmaWe wants to merge 1 commit into
Open
perf(l1): run batch block execution on spawn_blocking#7117NikhilSharmaWe wants to merge 1 commit into
NikhilSharmaWe wants to merge 1 commit into
Conversation
Signed-off-by: Nikhil Sharma <nikhilsharma230303@gmail.com>
Greptile SummaryThe PR moves full-sync batch block execution from Tokio async workers to the blocking pool and consolidates final batches onto the same validated, cancellable path.
Confidence Score: 5/5The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified. The unified path retains the prior bounded per-block execution and persistence behavior while adding cancellation and BAL commitment filtering to final batches; all repository call sites were migrated to the new ownership contract.
|
| Filename | Overview |
|---|---|
| crates/blockchain/blockchain.rs | Moves the existing batch loop to spawn_blocking while retaining cancellation, bounded persistence, BAL filtering, and failure metadata. |
| crates/networking/p2p/sync/full.rs | Removes the redundant final-batch implementation and routes every full-sync batch through the unified blockchain API without changing the common fork-choice update. |
| cmd/ethrex/cli.rs | Adapts block import to the consuming Arc<Self> receiver and owned BAL vector. |
| test/tests/blockchain/batch_tests.rs | Updates batch regression tests to exercise the new Arc<Blockchain> API. |
| test/tests/blockchain/canonical_commit_gate_tests.rs | Updates documentation to identify full-sync batch import as a bounded re-execution path. |
Sequence Diagram
sequenceDiagram
participant Sync as Full sync / CLI import
participant Async as Tokio async worker
participant Blocking as Tokio blocking pool
participant BC as Blockchain pipeline
participant Store as Store
Sync->>Async: add_blocks_in_batch(blocks, BALs, token)
Async->>Blocking: spawn_blocking(batch loop)
loop Each block
Blocking->>Blocking: Check cancellation
Blocking->>BC: add_block_pipeline_bounded
BC->>BC: Validate BAL commitment and execute
BC->>Store: Stage block and state updates
end
Blocking-->>Async: Batch result
Async-->>Sync: Success or failure metadata
Reviews (1): Last reviewed commit: "perf(l1): run batch block execution on s..." | Re-trigger Greptile
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.
Motivation
#7100 item 5:
add_blocks_in_batchran the per-block pipeline on a Tokio async worker, so full sync competed with RLPx and body download. The tip path already usedspawn_blocking.Description
spawn_blockingyield_now(can't await on the blocking pool)run_blocks_pipeline; final batches use the same path (cancel + BAL commitment filter)Test plan
cargo fmt --checkcargo check -p ethrex-blockchain -p ethrex-p2p -p ethrexcargo clippy -p ethrex-blockchain -p ethrex-p2p -- -D warningscargo test -p ethrex-test --test ethrex_tests batch_