Skip to content

timely-util: UnloadChunk, bulk probe extraction for chunk batches - #37954

Merged
DAlperin merged 1 commit into
mainfrom
dov/unload-chunk
Jul 30, 2026
Merged

timely-util: UnloadChunk, bulk probe extraction for chunk batches#37954
DAlperin merged 1 commit into
mainfrom
dov/unload-chunk

Conversation

@DAlperin

@DAlperin DAlperin commented Jul 29, 2026

Copy link
Copy Markdown
Member

Motivation

Part of the buffer-managed dataflow state work (doc/developer/design/20260610_buffer_managed_state.md, pool in #37718, configuration in #37719). This is the read capability the pool-spillable chunk stack builds on: the ColumnChunk PR stacks directly on this one, and upsert v2's stash drain is the production consumer. Upstream counterpart: TimelyDataflow/differential-dataflow#782.

Part of CPU-184.

Description

UnloadChunk is a second way to read a chunk, alongside the cursor: hand in a sorted, deduplicated column of probe keys and the matching updates are appended to caller-owned staging. locate answers where a probe falls relative to a chunk's key span from resident metadata only, so the batch driver can gallop the chunk list and open only chunks whose span contains a probe. Probes that fall in a gap between chunks are consumed without faulting any body. A probe equal to a chunk's last key is extracted but re-offered to the next chunk, since its group may continue there (the straddle protocol).

This PR is the trait and the batch-level driver only. The ColumnChunk implementation, including the spilled-body read path, is the next PR in the stack.

Verification

Contract tests over a miniature row family drive extraction across arbitrary chunk cuts and probe placements, straddled keys included, and compare against a reference filter of the raw rows.

UnloadChunk is the bulk-read capability for Chunk families: look up a
sorted set of keys in a chunk, copying the matching updates out into
caller-owned staging. Extraction is finished with a chunk's body when
the call returns, so a spilled body is read for the scope of one call
and no reference into pool memory exists outside it -- the contract
that lets a buffer pool evict with no reader accounting. The trait has
no key/val/time/diff opinions (Staging and Probes are family-chosen),
and the one comparison the batch driver needs is delegated to the chunk
via locate, answerable from resident metadata. Chunk boundaries are
carried as the consume-index protocol: a chunk consumes every probe
strictly below its last key and extracts-but-does-not-consume one equal
to it, re-offered to the next chunk as a legal straddle.

Ported from the differential fork (TimelyDataflow/differential-dataflow
PR 782) so consumers here depend on a local definition rather than a
git pin. One delta from the upstream shape: the batch driver is the
UnloadBatch extension trait rather than inherent methods on ChunkBatch
(not available to this crate); names and signatures match, so call
sites survive a future switch to upstream re-exports unchanged. If the
PR lands, this module retires in favor of re-exports.

Contract test: a miniature row family driven through every (chunk cut x
contiguous probe range) placement with a multi-chunk-spanning key,
against the reference filter.
@linear-code

linear-code Bot commented Jul 29, 2026

Copy link
Copy Markdown

CPU-184

@DAlperin
DAlperin marked this pull request as ready for review July 29, 2026 18:47
@DAlperin
DAlperin requested a review from a team as a code owner July 29, 2026 18:47
@DAlperin
DAlperin requested a review from frankmcsherry July 29, 2026 18:48

@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

@DAlperin
DAlperin merged commit a32ac9b into main Jul 30, 2026
125 checks passed
@DAlperin
DAlperin deleted the dov/unload-chunk branch July 30, 2026 15:40
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