Skip to content

DDIR Corgi join/arrange: four copy removals - #911

Merged
frankmcsherry merged 4 commits into
master-nextfrom
ddir-copy-removals
Sep 29, 2026
Merged

frankmcsherry merged 4 commits into
master-nextfrom
ddir-copy-removals

Conversation

@frankmcsherry

Copy link
Copy Markdown
Member

Four small changes that remove a copy or shorten a buffer's lifetime in the Corgi join and arrangement path. There is one commit each; each can be reviewed or dropped on its own.

  1. Borrow join comparison lanes. Comparison views used to gather temporary key columns before comparing them. They now borrow the chunk's u64 lanes with absolute row indices. Adds an oracle against structural row comparison.
  2. Skip the discarded hash column. Join output used to gather a compound key's identifier (hash) column and then drop it. It now borrows the declared key instead.
  3. The chunker takes the first input's buffers. When the accumulator is empty, the first input's time and diff buffers are swapped in instead of copied, and the chunker's empty buffers go back to the sender. Adds an oracle.
  4. Release merge planning buffers at their last use. The survey and offset buffers are dropped before the merge output is materialised, instead of at the end of the merge.

2 files, +135 −65.

The case for this is less copying and less held memory, not speed. Base is master-next 5fd3ecc and the candidate is this branch. Three pairs, order reversed in the middle pair, on an M4. The tour and SCC programs have their inspects removed. Medians:

Workload Workers Initial tick Ten churn ticks Peak footprint
tour 5k/10k 1 / 4 +0.4% / +0.4% +0.1% / 0.0% 0.0% / +0.8%
tour 50k/100k 1 −0.4% −0.5% −2.4% (0/3 higher; ranges separated)
tour 50k/100k 4 +1.1% −0.1% −0.5%
SCC 1 −1.1% (0/3 slower) +0.1% −1.3%
SCC 4 −1.4% (0/3 slower) −0.2% see below
AoC runner (wall) 1 / 4 −1.4% / −0.5%
  • Time: within ±1.4% everywhere.
  • Memory: the large tour's 1-worker peak falls 2.4% in every pair.
  • SCC 4-worker peak is noise. The first run showed +7.4%. A second run tested each cumulative prefix against base. Base alone ranged from 78.5 to 93.1 MiB over 12 runs (about ±9%), and no prefix separated from base. The full branch came out +5.8%, higher in 2 of 3 pairs, inside that spread. Of the four commits, only the chunker change (3) could plausibly hold more memory: it keeps the donated buffers' full capacity. If that matters, dropping commit 3 is independent of the others.

Earlier measurements on the worldgen DDIR tour:

  • the chunker change cut cumulative large allocations by 2 to 3%;
  • the merge release lowered the live-heap high-water from 787 to 759 MiB (−3.6%);
  • the hash-column skip removed about 26 MB of discarded copies per tour;
  • time was flat in all three.

Tests. cargo test --release -p interactive: 114 passed, 5 ignored (all ignored before this change too). All 33 AoC answers are checked on every run, and every timed tour and SCC output matches an oracle agreed by both backends.

The changes are by Astra (OpenAI Codex). I cherry-picked them onto master-next, resolved a test-only conflict with #908, and ran these measurements.

🤖 Generated with Claude Code

frankmcsherry and others added 4 commits September 28, 2026 20:51
The join's comparison views gathered temporary key columns before comparing
them. Borrow the chunk's u64 lanes with absolute row indices instead; the
owning chunks outlive the views. The structural fallback and the output
gathers are unchanged. Adds an oracle against structural row comparison for
sparse and skipped ranges.

Co-Authored-By: Astra (OpenAI Codex)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A compound key's arrangement carries an identifier (hash) column that join
output projections drop. Borrow the declared key before gathering output
instead of gathering the presented key and discarding its hash. Presented
keys stay for matching and collision checks.

Co-Authored-By: Astra (OpenAI Codex)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The chunker already took ownership of payload columns, but copied times and
diffs even when starting an empty batch. Swap the first input's owned buffers
into the empty accumulator and hand its empty buffers back to the sender;
later blocks append as before. Adds an oracle over single and multiple block
flushes, mixed PointStamp widths, and cancellation.

Co-Authored-By: Astra (OpenAI Codex)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The survey result is not read once output begins, and the source/offset
indices are not read once the surviving suffix is gathered. Drop them at their
last use rather than at the end of the merge, so they no longer overlap the
output's allocations. Output and API unchanged.

Co-Authored-By: Astra (OpenAI Codex)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@frankmcsherry
frankmcsherry merged commit d998c13 into master-next Sep 29, 2026
6 checks passed
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.

1 participant