Repository navigation
Experiment: sort runs in a fixed number of tasks - #21
Open
geoffreyclaude wants to merge 1 commit into
Open
geoffreyclaude wants to merge 1 commit into
geoffreyclaude wants to merge 1 commit into
Conversation
geoffreyclaude
force-pushed
the
codex/sort-preparation-grouped-experiment
branch
from
October 22, 2026 07:35
0c21ff4 to
67d73d5
Compare
geoffreyclaude
force-pushed
the
codex/sort-preparation-experiment-baseline
branch
from
October 22, 2026 07:35
20bd38d to
3b4ae7c
Compare
geoffreyclaude
force-pushed
the
codex/sort-preparation-grouped-experiment
branch
from
October 22, 2026 08:06
67d73d5 to
fc52bf2
Compare
geoffreyclaude
force-pushed
the
codex/sort-preparation-experiment-baseline
branch
from
October 22, 2026 08:06
3b4ae7c to
3e66732
Compare
Sort contiguous byte-balanced groups sequentially to compare task overhead and load balancing with per-run preparation. This commit was prepared with AI assistance.
geoffreyclaude
force-pushed
the
codex/sort-preparation-grouped-experiment
branch
from
October 22, 2026 08:20
fc52bf2 to
c0a27d1
Compare
This was referenced Oct 22, 2026
geoffreyclaude
marked this pull request as ready for review
October 22, 2026 11:53
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.
Fork-only experiment for comphead’s fixed-group suggestion.
Rationale for this change
DataFusion #26242 limits simultaneous sorting tasks but creates one task per run: an independently sorted piece of input that the final merge consumes.
Can a fixed number of larger tasks reduce this overhead without leaving sorting work unevenly distributed?
What changes are included in this PR?
per_partition_limitcontiguous groups, with approximately equal estimated memory sizes. This limit is the smaller of the Tokio worker count and available CPU parallelism.This removes per-run task creation and result reordering, while adding group balancing and resource ownership for whole groups.
What is the testing strategy for this PR?
Baseline: #26242 at
416c2d6.Run on 22 October 2026: Apple M1 Max, four Tokio workers, TPC-H SF1
lineitem(6,001,215 rows), optimizedrelease-nonltobuilds with mimalloc. Twelve balanced rounds per workload, with separate warmups; every measured run is retained.“Narrow” sorts three integer columns. “Wide” returns all 16 columns and sorts by four keys, including text. The output target is 8,192 rows. Preloaded cases exclude reading; Parquet cases include it. Sort timings exclude planning.
Median query execution times:
Conclusion: keep the per-run design in apache#26242. Fixed groups gained about 6% on the fragmented 32-row narrow sort, but cost 12.8% on wide Parquet (95% interval: +8.3% to +17.4%), 5.8% on preloaded wide input, and 9.0% with uneven work. In the uneven case, first output moved from 51 to 81 ms: finished groups cannot take work from a slower group.
Observed unrelated-query delays improved substantially. On the preloaded wide sort, the probe maximum fell from 42.4 to 0.8 ms.
Follow-up traces explain the gain: merge startup converts sort keys from every run’s first batch into a comparison format. In the baseline, all four workers could enter these long conversion loops at once. Fixed groups stagger merge startup, leaving workers available for other queries.
Focused tests cover group ordering, permit lifetime, cancellation, reservation cleanup and spilling.
Percentages above are median paired changes, which can differ from ratios of the table medians. Probe figures are medians of each run’s maximum
SELECT 1delay; short runs provide only dozens of probes. Timings use an unbounded memory pool.See the reproduction guide, all measurements, and summary with intervals.
Are there any user-facing changes?
Experimental internal scheduling; public configuration and output ordering are preserved. This draft is intended to support the design discussion.
This PR was prepared with AI assistance (GPT-6.1 Sol Ultra).