perf: Extend BufferPool recycling to all scratch-buffer encodings#804
Closed
xiaoxmeng wants to merge 1 commit into
Closed
perf: Extend BufferPool recycling to all scratch-buffer encodings#804xiaoxmeng wants to merge 1 commit into
xiaoxmeng wants to merge 1 commit into
Conversation
Summary: Previously only `MainlyConstantEncoding` used `BufferPool` to recycle scratch buffers across encoding lifetimes. This diff extends the pattern to `NullableEncoding`, `DeltaEncoding`, and `FixedBitWidthEncoding`, reducing MemoryPool allocation overhead during deserialization. Changes: - Added `getBuffer(bytes)`, `getVectorBuffer<V>()`, and `releaseVectorBuffer()` helpers to `Encoding` base class, replacing the local `detail::getPooledBuffer` in `MainlyConstantEncoding` - `getBuffer(bytes)` uses `BufferPool::get(bytes)` so undersized cached buffers remain available instead of being popped and released back - `NullableEncoding`: `nullBuffer_` now acquires/releases via BufferPool; removed dead `indicesBuffer_` member - `DeltaEncoding`: `deltasBuffer_`, `restatementsBuffer_`, and `isRestatementsBitmap_` now use BufferPool - `DictionaryEncoding` and `RLEEncoding`: dictionary-index scratch buffers now use BufferPool - `FixedBitWidthEncoding`: `buffer_` now uses BufferPool - `MainlyConstantEncoding`: refactored to use shared helpers (same behavior) - Removed dead `Vector<>` members: `SentinelEncoding::buffer_`, `VarintEncoding::buf_` - Added `EncodingBufferPoolTest.getBufferUsesMinimumCapacity` - Added serializer benchmark at `dwio/nimble/serializer/benchmarks/` measuring deserialization throughput and allocation counts with wide flat maps (BufferPool vs no BufferPool) Benchmark result highlight (10K rows x 100 keys, MainlyConstant data pattern): - Allocations: 602 (pool) vs 2302 (no pool) = 73.8% fewer allocs Differential Revision: D106908319
|
@xiaoxmeng has exported this pull request. If you are a Meta employee, you can view the originating Diff in D106908319. |
duxiao1212
approved these changes
May 31, 2026
|
This pull request has been merged in 566afa8. |
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.
Summary:
Previously only
MainlyConstantEncodingusedBufferPoolto recycle scratch buffers across encoding lifetimes. This diff extends the pattern toNullableEncoding,DeltaEncoding, andFixedBitWidthEncoding, reducing MemoryPool allocation overhead during deserialization.Changes:
getBuffer(bytes),getVectorBuffer<V>(), andreleaseVectorBuffer()helpers toEncodingbase class, replacing the localdetail::getPooledBufferinMainlyConstantEncodinggetBuffer(bytes)usesBufferPool::get(bytes)so undersized cached buffers remain available instead of being popped and released backNullableEncoding:nullBuffer_now acquires/releases via BufferPool; removed deadindicesBuffer_memberDeltaEncoding:deltasBuffer_,restatementsBuffer_, andisRestatementsBitmap_now use BufferPoolDictionaryEncodingandRLEEncoding: dictionary-index scratch buffers now use BufferPoolFixedBitWidthEncoding:buffer_now uses BufferPoolMainlyConstantEncoding: refactored to use shared helpers (same behavior)Vector<>members:SentinelEncoding::buffer_,VarintEncoding::buf_EncodingBufferPoolTest.getBufferUsesMinimumCapacitydwio/nimble/serializer/benchmarks/measuring deserialization throughput and allocation counts with wide flat maps (BufferPool vs no BufferPool)Benchmark result highlight (10K rows x 100 keys, MainlyConstant data pattern):
Differential Revision: D106908319