Skip to content

execution/commitment: reuse branch buffers instead of cloning every read - #23617

Open
awskii wants to merge 2 commits into
mainfrom
awskii/commitment-branch-bytes-reuse
Open

execution/commitment: reuse branch buffers instead of cloning every read#23617
awskii wants to merge 2 commits into
mainfrom
awskii/commitment-branch-bytes-reuse

Conversation

@awskii

@awskii awskii commented Aug 27, 2026

Copy link
Copy Markdown
Member

Commitment allocated a fresh copy on every branch read. TrieContext.Branch cloned each result, and getDeferredUpdate / mergeDeferredUpdate cloned prev and the merged encoded.

Changes

  • TrieContext.Branch copies into a per-context buffer; LatestCommitmentState clones at its own call site.
  • getDeferredUpdate takes prev through the existing reuseBytes instead of cloning — the nil-vs-empty contract it cited is what reuseBytes already implements.
  • mergeDeferredUpdate writes the merged value into a dedicated encodedBuf, so encoded either aliases raw or points at a buffer that survives pooling.
  • Tests pin the new contract: the buffer is reused across reads, and nil stays distinct from present-but-empty once it is warm.

Notes

Mainnet archive node syncing from genesis, 16 cores / 125 GB, --experimental.parallel-commitment, settled windows either side of the change:

metric before after
end-to-end 55.8 blk/s 75.9 blk/s
bytes.Clone 75.2 MB/s 13.4 MB/s
allocation per block 7.99 MB 6.26 MB
GC per block 6.25 mcore·s 3.21 mcore·s
total CPU 3.12 cores 3.18 cores

CPU is flat: the gain is GC pressure removed from the serial commitment path, not cycles saved.

@awskii
awskii requested review from mh0lt and taratorio as code owners August 27, 2026 05:49
@awskii
awskii requested a lite review from Copilot August 27, 2026 05:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@awskii
awskii requested a review from AskAlexSharov August 27, 2026 05:55
@awskii awskii added this to the 3.6.1 milestone Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants