fix(archiver): avoid loading full blocks during checkpoint ingestion - #25279
Open
spalladino wants to merge 1 commit into
Open
fix(archiver): avoid loading full blocks during checkpoint ingestion#25279spalladino wants to merge 1 commit into
spalladino wants to merge 1 commit into
Conversation
Checkpoint ingestion validated chaining by fetching the previous checkpoint's last block as a full L2Block inside the write transaction, deserializing every tx effect for four header fields. Read the lightweight block data instead, and hoist the per-tx/per-block hash serialization out of the log indexing loop. Cuts per-checkpoint ingestion time by 49%/42% at 36/120 txs per block.
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.
Context
The archiver ingests each checkpoint inside a single
transactionAsync, so ingestion duration directly delays any read queued behind it (notablygetLogsByTags, see #25254). Profiling showed the single biggest cost was not the write itself:getPreviousCheckpointBlockfetched the previous checkpoint's last block as a fullL2Block— one sequential native LMDB round trip plus deserialization per tx effect — when its only consumer,validateCheckpointBlocks, reads four header-level fields.Approach
getPreviousCheckpointBlocknow reads the lightweight block data (asaddProposedBlockalready does) and returns just the chaining info (number,checkpointNumber,indexWithinCheckpoint,archive).L2Blocksatisfies the shape structurally, so the validation body, error types, and messages are unchanged.LogStore.addLogsserialized the sametxHashonce per log and the sameblockHashonce per log in the whole block; both are now serialized once per tx / once per block and passed toencodeValuepre-serialized. The stored byte format is unchanged.Measured A/B (per-checkpoint ingestion
addCheckpoints+addLogs, LMDB on NVMe, mean of 10 checkpoints after warmup, two runs each):