Repository navigation
Conversation
Spill independent sorted runs when a large multi-key sort has potentially expanding keys and less retained merge workspace than buffered reservation. Keep fixed-width keys and better-reserved merges on the existing preparation path. Hold shared input, per-run reservations, and merge workspace across asynchronous writes. Add an exact-output public SortExec regression and later-write lifetime coverage for success, failure, and cancellation. Amp-Thread-ID: https://ampcode.com/threads/T-92ab84e1-4bd7-42d2-9885-8e81c665fab6 Co-authored-by: Amp <amp@ampcode.com>
22 of 47 tasks
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.
Which issue does this PR close?
Related to #26940.
Rationale for this change
Multi-key sorts can run out of memory while trying to spill. Initializing merge cursors for all buffered batches can expand dictionary keys beyond the available memory before any data is written.
What changes are included in this PR?
Spill buffered batches as independent sorted runs for large multi-key sorts with potentially expanding keys when the buffered reservation exceeds reserved merge workspace. Keep the existing path otherwise.
The workspace comparison is a heuristic, not a bound on encoded key memory.
Related to #26953 and #26987. #26953 reduces merge input batch sizes; this avoids the ingestion-time merge for selected spills, including small batches that #26953 leaves unchanged. #26987 bounds the batches written to spill files for subsequent merging.
Also complementary to #27015, which reduces dictionary data written to disk.
What is the testing strategy for this PR?
Unit tests for wide dictionary keys and reservation lifetimes during async writes, including errors and cancellation. Extended workspace tests and Clippy pass.
Are there any user-facing changes?
No API changes, just an improvement to ingestion-time spilling. The tradeoff is more spill files and potentially more merge I/O for the selected path.
@alamb @Jefffrey