Skip to content

row-spine: back production spines with Arc for cross-thread arrangement sharing#37881

Open
antiguru wants to merge 2 commits into
MaterializeInc:mainfrom
antiguru:claude/spines-differential-arc-j93mho
Open

row-spine: back production spines with Arc for cross-thread arrangement sharing#37881
antiguru wants to merge 2 commits into
MaterializeInc:mainfrom
antiguru:claude/spines-differential-arc-j93mho

Conversation

@antiguru

@antiguru antiguru commented Jul 24, 2026

Copy link
Copy Markdown
Member

Motivation

Cross-runtime arrangement sharing (the two-runtime read-isolation work, #37770)
needs batches readable from a thread other than the one maintaining the trace.
Differential's default spines reference-count batches with Rc, which is
worker-local.

Description

Introduce mz_row_spine::ArcBatch, a local newtype around Arc<B> that carries
differential's batch traits (the orphan rule forbids the blanket impl on a bare
Arc<B>), and switch the production spines and their builders — RowRowSpine,
RowValSpine, RowSpine, ValRowSpine, ColValSpine, ColKeySpine — from
Rc/RcBuilder to ArcBatch/ArcBuilder. An Arc-backed batch whose contents
are Send + Sync can be read across threads, which Rc cannot do. Only the
batch handle becomes atomic; the batch contents are unchanged, so the cost is a
marginally more expensive refcount.

Also adds generic ArcOrdVal/ArcOrdKeySpine aliases for callers outside
mz_compute, adapts batch-size logging (log_arrangement_size_inner) to reach
through the newtype to the inner Arc, and switches the storage sink trace to
the Arc-backed spine.

Builds against released differential-dataflow 0.25 with no fork or
[patch.crates-io].

Context

Extracted from #37770 for standalone review; #37770 builds on this.

Verification

cargo check --workspace on top of main passes (6 files changed, no
Cargo.lock churn, no other crate affected by the RcArc switch).

🤖 Generated with Claude Code

Introduce `mz_row_spine::ArcBatch`, a local newtype around `Arc<B>` carrying
differential's batch traits (the orphan rule forbids the blanket impl on a bare
`Arc<B>`), and switch the production spines and their builders — `RowRowSpine`,
`RowValSpine`, `RowSpine`, `ValRowSpine`, `ColValSpine`, `ColKeySpine` — from
`Rc`/`RcBuilder` to `ArcBatch`/`ArcBuilder`. An `Arc`-backed batch whose contents
are `Send + Sync` can be read from a thread other than the one maintaining the
trace, which `Rc` cannot do. Only the batch handle becomes atomic; the batch
contents are unchanged.

Also add generic `ArcOrdVal`/`ArcOrdKeySpine` aliases for callers outside
`mz_compute`, adapt batch-size logging (`log_arrangement_size_inner`) to reach
through the newtype to the inner `Arc`, and switch the storage sink trace to the
`Arc`-backed spine.

This is the foundational primitive the two-runtime read-isolation work (MaterializeInc#37770)
builds on, extracted here for standalone review. It builds against released
differential-dataflow with no fork or `[patch.crates-io]`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CY7GHdrTBfAG4tgvSgPGJ9
The introspection golden prints the Rust type name of each arrangement's batch
allocation. Switching the production spines to `ArcBatch` changes that name from
`alloc::rc::Rc<OrdValBatch<..>>` to `mz_row_spine::arc_batch::ArcBatch<OrdValBatch<..>>`.
Churn only, 42 symmetric type-name substitutions, no operator-graph change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CY7GHdrTBfAG4tgvSgPGJ9
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