release-21.1: storage: pool pebbleReadOnly allocations #63972
Merged
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.
Backport 1/1 commits from #63845.
/cc @cockroachdb/release
This commit introduces object pooling for
pebbleReadOnly
allocation avoidance. I found this to be important both because it avoids the initialpebbleReadOnly
allocation, but also because it allows the memory recycling inside of eachpebbleIterator
owned by apebbleReadOnly
to work correctly.I found this while running a few microbenchmarks and noticing that the lockTable's calls to
intentInterleavingReader
were resulting in a large number of heap allocations in(*pebbleReadOnly).NewEngineIterator
. This was becauselowerBoundBuf
andupperBoundBuf
were always nil and so each append (all 4 of them) in(*pebbleIterator).init
was causing an allocation.We may want to consider this as a candidate to backport to release-21.1, because the lack of pooling here was even more detrimental with the separated lockTable, which creates a separate
EngineIterator
with lower and upper bounds. So this may have a small impact on #62078.Release note (performance improvement): A series of heap allocations performed when serving read-only queries are now avoided.