Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(batch): support spill hash agg for the batch query #16771

Merged
merged 22 commits into from
May 29, 2024

Conversation

chenzl25
Copy link
Contributor

@chenzl25 chenzl25 commented May 15, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • Related RFC: RFC: Spill Hash Aggregation rfcs#89
  • Tracking issue Tracking: batch query memory control and spill #16615
  • Support spill hash agg for the batch query.
  • When HashAggExecutor told memory is insufficient, AggSpillManager will start to partition the hash table and spill to disk. After spilling the hash table, AggSpillManager will consume all chunks from the input executor, partition and spill to disk with the same hash function as the hash table spilling. Finally, we would get e.g. 20 partitions. Each partition should contain a portion of the original hash table and input data. A sub HashAggExecutor would be used to consume each partition one by one. If memory is still not enough in the sub HashAggExecutor, it will partition its hash table and input recursively.
  • SpillOp is used to manage the spill directory of the spilling executor and it will drop the directory with a RAII style.
  • An environment variable RW_BATCH_SPILL_DIR would be used to configure the path to spill, by default /tmp/.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

  • Support spill hash agg for the batch query.

Copy link
Contributor

@st1page st1page left a comment

Choose a reason for hiding this comment

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

Maybe we need to test the case that the directory of the FS is full? And how to GC the spilled data 🤔

src/batch/src/spill/spill_op.rs Show resolved Hide resolved
@chenzl25
Copy link
Contributor Author

Maybe we need to test the case that the directory of the FS is full? And how to GC the spilled data 🤔

If the disk is full, the IO should throw an error. When the query is aborted, it will release its disk occupation.

@st1page
Copy link
Contributor

st1page commented May 17, 2024

Maybe we need to test the case that the directory of the FS is full? And how to GC the spilled data 🤔

If the disk is full, the IO should throw an error. When the query is aborted, it will release its disk occupation.

Yes, And maybe we need to clean the spilled file somewhere when the batch task is dropped

Copy link
Contributor

@fuyufjh fuyufjh left a comment

Choose a reason for hiding this comment

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

Overall LGTM

src/batch/src/executor/hash_agg.rs Outdated Show resolved Hide resolved
src/batch/src/executor/hash_agg.rs Show resolved Hide resolved
src/batch/src/error.rs Outdated Show resolved Hide resolved
src/common/src/config.rs Show resolved Hide resolved
src/config/docs.md Outdated Show resolved Hide resolved
src/expr/core/src/aggregate/mod.rs Show resolved Hide resolved
src/batch/src/executor/hash_agg.rs Outdated Show resolved Hide resolved
src/batch/src/executor/hash_agg.rs Show resolved Hide resolved
src/batch/src/executor/hash_agg.rs Show resolved Hide resolved
@chenzl25 chenzl25 added the user-facing-changes Contains changes that are visible to users label May 29, 2024
@chenzl25 chenzl25 enabled auto-merge May 29, 2024 10:55
@chenzl25 chenzl25 added this pull request to the merge queue May 29, 2024
Merged via the queue into main with commit c7ad769 May 29, 2024
28 of 29 checks passed
@chenzl25 chenzl25 deleted the dylan/support_spill_agg branch May 29, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants