Skip to content

perf: reuse quantile summary buffers during merge#4932

Open
peterxcli wants to merge 1 commit into
apache:mainfrom
peterxcli:perf/reduce-approx-percentile-byte
Open

perf: reuse quantile summary buffers during merge#4932
peterxcli wants to merge 1 commit into
apache:mainfrom
peterxcli:perf/reduce-approx-percentile-byte

Conversation

@peterxcli

Copy link
Copy Markdown
Member

Which issue does this PR close?

Closes #4874.

Rationale for this change

The native QuantileSummaries port behind approx_percentile / percentile_approx allocates more than necessary on its hot paths:

  • QuantileSummaries::merge takes &self / &other and allocates a fresh summary, so merge_batch reallocates on every incoming digest.
  • with_head_buffer_inserted rebuilds the whole sampled vector on every flush.

What changes are included in this PR?

  • Reuse scratch buffers in QuantileSummaries during flush, compression, and merge.
  • Change summary merging to update in place while preserving the first-digest move fast path.
  • Update memory accounting and add a regression test for buffer reuse.

How are these changes tested?

benchmark

result:

  • merge_batch: (15GB -> 11GB)
    • upstream: image
    • pr: image
  • with_head_buffer_inserted: (10GB -> 1GB)
    • upstream: image
    • pr: image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce allocations in approx_percentile QuantileSummaries merge and flush paths

1 participant