Reuse batchesBuf across series via BufferCarrier - #7782
Open
PaurushGarg wants to merge 1 commit into
Open
Conversation
PaurushGarg
force-pushed
the
fix/buffer-carrier
branch
from
August 19, 2026 22:26
695c264 to
5f8537c
Compare
Signed-off-by: Paurush Garg <paurushg@amazon.com>
PaurushGarg
force-pushed
the
fix/buffer-carrier
branch
from
August 19, 2026 22:31
5f8537c to
5b51fb8
Compare
Contributor
Author
|
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.
What this PR does:
Each
mergeIteratorallocates its ownbatchesBuf(~1200 bytes) at creation time. For engines that allocate all iterators upfront (without series batching), this adds to the heap - while only one buffer is actively used at a time since series are processed sequentially within a shard.This PR adds a
bufProviderinterface that allows an upstream caller to pass a shared buffer throughs.Iterator(carrier). The first series allocates the buffer and writes it back to the carrier; all subsequent series reuse it. When no carrier is passed (nil), each iterator allocates its own buffer as before.The companion promql-engine PR passes a
BufferCarrierfrom thematrixSelector, enabling the reuse.Benchmark
Added
BenchmarkNewChunkMergeIterator_BufferCarrierwhich compares:no_carrier: creates 10K iterators passing nil (current behavior — each allocates own buffer)with_carrier: creates 10K iterators passing a shared carrier (new behavior — one buffer reused)Results here shows -13.1% memory, -10K allocations, no speed regression. Savings are ~1280 bytes/series.
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]docs/configuration/v1-guarantees.mdupdated if this PR introduces experimental flags