Skip to content

fix: account for memory that we still hold on when splitting batch - #24852

Open
rluvaton wants to merge 2 commits into
apache:mainfrom
rluvaton:add-unaccounted-memory
Open

fix: account for memory that we still hold on when splitting batch#24852
rluvaton wants to merge 2 commits into
apache:mainfrom
rluvaton:add-unaccounted-memory

Conversation

@rluvaton

@rluvaton rluvaton commented Sep 1, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

N/A

Rationale for this change

hold on batches between emit should be reserved

What changes are included in this PR?

reserve memory + test

What is the testing strategy for this PR?

unit test

Are there any user-facing changes?

no

@github-actions github-actions Bot added the physical-plan Changes to the physical-plan crate label Sep 1, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.93151% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.60%. Comparing base (2215238) to head (85d9ef7).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...fusion/physical-plan/src/aggregates/hash_stream.rs 84.93% 3 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24852      +/-   ##
==========================================
+ Coverage   81.59%   81.60%   +0.01%     
==========================================
  Files        1123     1123              
  Lines      408413   408974     +561     
  Branches   408413   408974     +561     
==========================================
+ Hits       333230   333740     +510     
- Misses      55615    55621       +6     
- Partials    19568    19613      +45     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

self.reservation.try_resize(hash_table.memory_size());
let resize_result = self
.reservation
.try_resize(hash_table.memory_size() + state_batch_size);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This follows a failed resize, so charging the retained batch can make early emission fail with OOM after the batch is already allocated. If it cannot be retained, preserve progress (for example, yield it whole).

PartialHashAggregateState::EmittingOnMemoryPressure {
hash_table,
remaining_groups: materialized_group_states,
batch_memory_size: state_batch_size,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MaterializedAggregateOutput already implements this materialize-once/slice-many lifecycle. Reuse it with a split child MemoryReservation, and test that the reservation drops after the last slice before polling to Done.

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

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants