Skip to content

share batchesBuf across merge iterators via MergeWorkspace - #7765

Draft
PaurushGarg wants to merge 1 commit into
cortexproject:masterfrom
PaurushGarg:fix/shared-batches-buf-v2
Draft

share batchesBuf across merge iterators via MergeWorkspace#7765
PaurushGarg wants to merge 1 commit into
cortexproject:masterfrom
PaurushGarg:fix/shared-batches-buf-v2

Conversation

@PaurushGarg

Copy link
Copy Markdown
Contributor

What this PR does:
Each mergeIterator allocates its own batchesBuf at creation time. This adds to the heap profile for query engines that create all iterators upfront, especially with high-cardinality queries - while only one buffer is actively used at a time since series are processed sequentially.

Add MergeWorkspace is a shared buffer that multiple merge iterators can borrow instead of allocating their own. batchesBuf is scratch space used only during buildNextBatch() and overwritten every call.

buildNextBatch lazily allocates its own buffer if no workspace is passed.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
  • docs/configuration/v1-guarantees.md updated if this PR introduces experimental flags

@PaurushGarg
PaurushGarg force-pushed the fix/shared-batches-buf-v2 branch from cb83e77 to 3fb8a9c Compare August 14, 2026 23:50
Signed-off-by: Paurush Garg <paurushg@amazon.com>
@PaurushGarg
PaurushGarg force-pushed the fix/shared-batches-buf-v2 branch from 3fb8a9c to 9706212 Compare August 15, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant