Relocate batch merging traits into the fueled spine - #841
Merged
Conversation
The Merger trait and the Batch::Merger associated type were consumed only by spine_fueled.rs, but lived on the common Batch trait, obliging every batch type to carry this one spine's merge opinion. Move them into the spine as a spine-local trait, SpineBatch: Batch, along with the Rc forwarding (RcMerger). The common Batch trait retains only `empty`, which has a consumer outside the spine: TraceWriter::seal mints empty batches to pad otherwise empty intervals of time. Implementors (OrdValBatch, OrdKeyBatch, ChunkBatch) split their impls accordingly. No behavior changes; call sites are path and name updates only. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
frankmcsherry
marked this pull request as ready for review
August 24, 2026 17:12
`SpineBatch::begin_merge` and `Merger::new` were two entry points to the same construction, and the two implementors overrode `begin_merge` with the trait's own default body. Keep `Merger::new` and drop `begin_merge`; `SpineBatch` is now just the association of a batch type with its merger, and the documentation of what starting a merge means moves to `Merger` itself. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
What
Moves the
Mergertrait and theBatch::Mergerassociated type out oftrace/mod.rsand intospine_fueled.rs, as a spine-local trait:SpineBatch: Batch(inspine_fueled.rs) associates a batch type with itsMerger. TheRcforwarding (RcMerger,impl SpineBatch for Rc<B>) moves alongside it.Batch(intrace/mod.rs) retains onlyempty, which has a consumer outside the spine:TraceWriter::sealmints empty batches to pad otherwise empty intervals of time, so empty-minting is a property of writable traces generally, not a spine opinion.OrdValBatch,OrdKeyBatch,ChunkBatch) split into a one-methodimpl Batchand a separateimpl SpineBatch.Batch::begin_mergedoes not survive the move. It andMerger::newwere two entry points to the same construction, and both implementors overrodebegin_mergewith the trait's own default body. OnlyMerger::newremains; the documentation of what beginning a merge means moves ontoMerger. The spine's ownMergeState::begin_merge, which handles the structurally-empty cases, is unaffected.No behavior changes; all other edits are path and name updates (including three test modules).
Why
An audit showed the merge machinery had exactly one consumer: the fueled spine. Different trace maintenance strategies want differently shaped merge contracts (compare
merge_batcher's ownMerger, which owns its input chains), so the progressive-merge signature is an opinion of this spine rather than a property of batches in general. Relocating it makes later changes to that opinion — e.g. merge state that owns its inputs and releases them incrementally, to avoid the 2x memory spike during merges of chunk batches — local to the spine instead of revisions to the common batch contract.Verification
cargo build --workspace(and--examples),cargo test --workspace --lib, andcargo test -p differential-dataflow --testsall pass;cargo docintroduces no new warnings.🤖 Generated with Claude Code