feat: add storagechange object pool for better performance#3112
Merged
MatusKysel merged 2 commits intodevelopfrom May 22, 2025
Merged
feat: add storagechange object pool for better performance#3112MatusKysel merged 2 commits intodevelopfrom
MatusKysel merged 2 commits intodevelopfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds an object pool for storageChange entries to cut down on allocations and GC pressure when journalling state changes.
- Introduces
sync.Poolfor reusablestorageChangeinstances - Converts
storageChangemethods to pointer receivers and updates journal operations to track and reset pooled entries - Optimizes
journal.copy()and slice pre-allocation
da77009 to
4d6b5cb
Compare
4d6b5cb to
fb5b816
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves memory allocation performance in the state journal by reusing storageChange objects via a sync.Pool.
- Introduces a
storageChangePooland updatesstorageChangemethods to pointer receivers - Tracks pooled
storageChangeobjects injournal.storageEntriesand returns them injournal.reset - Optimizes
journal.copyto pre-allocate slices and clone existing data
Comments suppressed due to low confidence (1)
core/state/journal.go:63
- Add unit tests for the pooling behavior (e.g., verify that
resetreturns objects to the pool and that subsequentGetcalls reuse instances) to catch regressions in memory reuse.
var storageChangePool = sync.Pool{
buddh0
reviewed
May 21, 2025
buddh0
reviewed
May 21, 2025
0627051 to
955773c
Compare
zzzckck
approved these changes
May 22, 2025
buddh0
approved these changes
May 22, 2025
This was referenced May 28, 2025
Merged
This was referenced Jun 16, 2025
Merged
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.
Description
This PR introduces an object pool for
storageChangeentries in the state journal to improve memory allocation performance. The changes include:sync.PoolforstorageChangeobjects to reduce GC pressurestorageChangemethods to work with pointers instead of valuesChanges
storageChangePoolusingsync.Poolfor efficient object reusestorageChangemethods to use pointer receiversjournal.copy()to pre-allocate slices with exact capacitystorageChangeoperationsPerformance Impact
The changes reduce memory allocations by:
storageChangeobjects instead of creating new onesBenchmark
Old profile (note % not total GB as I was running it for different blocks)


New Profile after the change