Skip to content

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

Merged
antiguru merged 2 commits into
mainfrom
mh/interactive-00-arc-spines
Aug 21, 2026
Merged

row-spine: back production spines with Arc for cross-thread arrangement sharing#38396
antiguru merged 2 commits into
mainfrom
mh/interactive-00-arc-spines

Conversation

@antiguru

Copy link
Copy Markdown
Member

Replaces #37881, whose head branch lives on a fork and so cannot be the base of a stacked PR in this repository. Same commits, same tree, on an upstream branch instead. This is the root of the stack #38386 through #38393, which splits #37770.

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].

Verification

cargo check --workspace passes with no Cargo.lock churn. relations.slt's golden is rewritten because the spine type name appears in operator names.

🤖 Generated with Claude Code

antiguru and others added 2 commits August 21, 2026 15:42
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.

Two consumers of the sink trace follow from that switch. The iceberg sink stashes
input batches while it waits for their batch description, so its `VecDeque` and
the `with_ready_batches` helper now hold `ArcBatch` rather than `Rc`. And the
arrangement-size operator's cache comment named the `RcBox` allocation its `Weak`
keeps reserved, which is an `ArcInner` once the batch handle is atomic. The
invariant it documents is unchanged.

This is the foundational primitive the two-runtime read-isolation work (#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 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019G29DBfgE8LXpE5jamm2Zi
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 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019G29DBfgE8LXpE5jamm2Zi
@antiguru
antiguru force-pushed the mh/interactive-00-arc-spines branch from 87c4c30 to 470ef63 Compare August 21, 2026 13:42

@frankmcsherry frankmcsherry left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@antiguru
antiguru merged commit 98ea0cc into main Aug 21, 2026
83 checks passed
@antiguru
antiguru deleted the mh/interactive-00-arc-spines branch August 21, 2026 14:31
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.

2 participants