Skip to content

test(dataset): check spilled row lineage against inline lineage - #9791

Merged
BubbleCal merged 1 commit into
mainfrom
yang/oss-2440-spilled-lineage-op-matrix
Oct 8, 2026
Merged

BubbleCal merged 1 commit into
mainfrom
yang/oss-2440-spilled-lineage-op-matrix

Conversation

@BubbleCal

Copy link
Copy Markdown
Contributor

Problem

Spilled row lineage (#9250) is about to be declared stable. The tests in rust/lance/src/dataset/rowids/spill.rs each pin how one write places lineage, but nothing checks what a sequence of later operations does to lineage that is already spilled. That is where it has broken: #9623 fixed an update that dropped a fragment's lineage-only file because no schema field lived in it, and none of the existing tests caught it.

What changed

Adds spilled_lineage_reads_like_inline_lineage, a differential test in rust/lance/src/dataset/rowids/spill.rs. Each scenario runs the same steps on two tables: one that spills every sequence (inline budget 0) and one that keeps them inline, as released builds do. After every step it asserts that:

  • every row has the same row id, created-at and last-updated-at version on both tables, and keys stay unique;
  • both tables validate, and take_rows by row id returns the right rows;
  • a filter on j returns the same rows, through the zone map and the fragment reuse index where a scenario builds them;
  • the spilled table sets the spilled-lineage feature flag exactly when a fragment spills, and the inline table never spills.

At the end both tables are reopened cold and every version they keep is compared.

The 18 scenarios cover:

  • consecutive updates, deletes and appends;
  • upserts and in-place column patches through merge_insert;
  • add, cast and drop column, Dataset::merge and DataReplacement;
  • reencode, binary-copy and deferred-remap compaction, the last with a zone map so a fragment reuse index is written;
  • a compaction racing an append or a delete, and an update racing a compaction;
  • restore, cleanup, shallow and deep clone, and branches.

A compaction whose fragments receive a concurrent delete loses with a retryable conflict on both tables. That is existing behavior; the scenario asserts it and checks that both tables still agree afterwards.

Validation

  • All 54 tests in dataset::rowids::spill pass. Each new case takes at most 0.43 s in a debug build, including process startup.
  • Reverting the fix from fix(table): preserve spilled row lineage during updates #9623 in manifest_build.rs makes all 18 scenarios fail with the error that PR describes.
  • cargo fmt --all -- --check and cargo clippy --all --tests --benches -- -D warnings pass.

Run on an x86 Linux VM (r8i.8xlarge).

Limitations

Not covered: overwrite, merge_insert racing other writes, remote object stores (the scenarios use the local filesystem), spilling at the default 200 KiB budget (every scenario uses budget 0), and the Python and Java bindings.

Refs #9250

🤖 Generated with Claude Code

Run 18 operation sequences on a table that spills every row lineage
sequence and on one that keeps them inline, and compare every row's id,
created-at and last-updated-at version after each step. The existing
tests pin how each write places lineage; these cover what later
operations do with lineage that is already spilled, ahead of declaring
the format stable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added the chore label Oct 8, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

✅ Gate recommendation: approve.

No merge-blocking issue found. All 54 spill tests passed locally; temporarily reintroducing the lineage-file pruning regression fixed in #9623 made all 18 new cases fail.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Oct 8, 2026
@BubbleCal
BubbleCal merged commit 66cc6b7 into main Oct 8, 2026
@BubbleCal
BubbleCal deleted the yang/oss-2440-spilled-lineage-op-matrix branch October 8, 2026 17:21
BubbleCal added a commit that referenced this pull request Oct 11, 2026
Spilled row lineage has readers, writers and the operation matrix from
#9791, but the spec still marks it as unreleased. This declares the
existing format stable, names bit 11 `FLAG_SPILLED_ROW_LINEAGE`, and
states that disabling future spills does not disable reads of existing
spilled sequences.

The wire layout, bit value, V2-only boundary and table opt-in stay
unchanged. The runtime change is in #9802; this PR changes only format
documentation and protobuf comments. The first library release with
unconditional support will be recorded once that implementation lands.

Validation: `python3 ci/check_proto_comments.py
protos/fragment_metadata.proto`, `git diff --check`, and the
repository's typos and proto-comment hooks pass.

## Historical benchmark: inline vs spilled

The 400,000-row smoke run reported in #9340 compared inline and spilled
lineage within the same implementation. These are historical results for
the storage trade-off; performance gains against the current head of
this specification PR have not been measured.

Configuration: x86 r8i.8xlarge, local filesystem, `release-with-debug`,
2 fragments x 200,000 rows, and `BENCH_INLINE_MAX_BYTES=0` to force
spilling. Each arm ran once; timing rows report medians of samples
within that run. `shuffled` rewrites rows in random physical order
before compaction; `deleted` compacts after deletions. Lower is better
for every metric below.

| Scenario / metric | Inline | Spilled | Effect |
| --- | ---: | ---: | ---: |
| Shuffled / Steady-state manifest | 7.49 MiB | < 0.01 MiB | ~10,367x
smaller |
| Shuffled / Cold dataset open (median) | 4.32 ms | 0.12 ms | 36.5x
faster |
| Shuffled / Append commit (median) | 6.27 ms | 0.78 ms | 8.1x faster |
| Shuffled / Cold row-ID index build (median) | 36.11 ms | 35.53 ms |
~1.0x |
| Shuffled / Cold sequence load (median) | 0.18 ms | 1.97 ms | ~10.9x
slower |
| Shuffled / Compaction data-file bytes | 1.93 MiB | 2.96 MiB | ~1.53x
larger |
| Deleted / Steady-state manifest | 0.14 MiB | < 0.01 MiB | ~237x
smaller |
| Deleted / Cold row-ID index build (median) | 2.53 ms | 5.48 ms |
~2.17x slower |

Sizes are MiB, matching the [benchmark's
formatter](https://github.com/lance-format/lance/blob/8ebfde6f094c26e79602cf6c619929c137cbf5a5/rust/lance/benches/rowid_spill.rs#L829);
#9340 labeled them MB. Reported speedups and size reductions use
unrounded values; slowdown and growth factors above are approximate.

The main benefit in this run is smaller manifests and cheaper
open/commit work for shuffled lineage. Full-table row-ID index
construction stays about the same. The cost moves to the first sequence
read and to larger compaction output, so the open speedup is not an
end-to-end query speedup.

Scope: “cold” means a fresh Lance session with its caches disabled,
without evicting the OS page cache. Append timing covers the commit
only, excluding data-file writes. This single run does not establish
multi-run variance, remote-storage performance, or behavior under the
default 200 KiB budget. The later 2 x 2,000-row run for #9802 validates
functionality with the env var unset; it is not another performance
measurement. The table above comes from #9340's published summary; the
original run SHA and raw log were not recovered.

Refs #9250; follows #9791.
BubbleCal added a commit that referenced this pull request Oct 14, 2026
Re-proposes #9800 after #9885 reverted its premature merge. The file
changes are identical; this PR restarts the format vote.

Spilled row lineage has readers, writers and the operation matrix from
#9791, but the spec still marks it as unreleased. This declares the
existing format stable, names bit 11 `FLAG_SPILLED_ROW_LINEAGE`, and
states that disabling future spills does not disable reads of existing
spilled sequences.

The wire layout, bit value, V2-only boundary and table opt-in stay
unchanged. The runtime change is in #9802; this PR changes only format
documentation and protobuf comments. The first library release with
unconditional support will be recorded once that implementation lands.

Validation: `python3 ci/check_proto_comments.py
protos/fragment_metadata.proto`, `git diff --check`, and the
repository's typos and proto-comment hooks pass.

## Historical benchmark: inline vs spilled

The 400,000-row smoke run reported in #9340 compared inline and spilled
lineage within the same implementation. These are historical results for
the storage trade-off; performance gains against the current head of
this specification PR have not been measured.

Configuration: x86 r8i.8xlarge, local filesystem, `release-with-debug`,
2 fragments x 200,000 rows, and `BENCH_INLINE_MAX_BYTES=0` to force
spilling. Each arm ran once; timing rows report medians of samples
within that run. `shuffled` rewrites rows in random physical order
before compaction; `deleted` compacts after deletions. Lower is better
for every metric below.

| Scenario / metric | Inline | Spilled | Effect |
| --- | ---: | ---: | ---: |
| Shuffled / Steady-state manifest | 7.49 MiB | < 0.01 MiB | ~10,367x
smaller |
| Shuffled / Cold dataset open (median) | 4.32 ms | 0.12 ms | 36.5x
faster |
| Shuffled / Append commit (median) | 6.27 ms | 0.78 ms | 8.1x faster |
| Shuffled / Cold row-ID index build (median) | 36.11 ms | 35.53 ms |
~1.0x |
| Shuffled / Cold sequence load (median) | 0.18 ms | 1.97 ms | ~10.9x
slower |
| Shuffled / Compaction data-file bytes | 1.93 MiB | 2.96 MiB | ~1.53x
larger |
| Deleted / Steady-state manifest | 0.14 MiB | < 0.01 MiB | ~237x
smaller |
| Deleted / Cold row-ID index build (median) | 2.53 ms | 5.48 ms |
~2.17x slower |

Sizes are MiB, matching the [benchmark's
formatter](https://github.com/lance-format/lance/blob/8ebfde6f094c26e79602cf6c619929c137cbf5a5/rust/lance/benches/rowid_spill.rs#L829);
#9340 labeled them MB. Reported speedups and size reductions use
unrounded values; slowdown and growth factors above are approximate.

The main benefit in this run is smaller manifests and cheaper
open/commit work for shuffled lineage. Full-table row-ID index
construction stays about the same. The cost moves to the first sequence
read and to larger compaction output, so the open speedup is not an
end-to-end query speedup.

Scope: “cold” means a fresh Lance session with its caches disabled,
without evicting the OS page cache. Append timing covers the commit
only, excluding data-file writes. This single run does not establish
multi-run variance, remote-storage performance, or behavior under the
default 200 KiB budget. The later 2 x 2,000-row run for #9802 validates
functionality with the env var unset; it is not another performance
measurement. The table above comes from #9340's published summary; the
original run SHA and raw log were not recovered.

Refs #9250; follows #9791.
BubbleCal added a commit that referenced this pull request Oct 14, 2026
Setting `lance.row_lineage.spill=true` currently does nothing in a
release build unless `LANCE_ENABLE_UNSTABLE_SPILLED_ROW_LINEAGE` is also
set. This makes bit 11 supported in every build and lets table
configuration alone control new spills. Readers continue to load
existing spilled sequences after spilling is disabled.

The default stays off, the inline budget stays 200 KiB, and V1 files
stay inline. `FLAG_SPILLED_ROW_LINEAGE` replaces the unstable name,
which remains as a deprecated alias. The unused environment-variable
constant and support helper are removed. The benchmark no longer
requires the env var.

Extends the existing tests for absent/false configuration, the default
threshold, and disabling spill before a cold reopen and a compaction
back to inline. The deferred-remap matrix case checks its independent
FRI gate in each build profile.

Includes the accepted format specification from #9886, which satisfies
the storage-contract prerequisite for unconditional runtime support.
Compaction tests use the stable flag name so integration with main does
not fail on deprecation warnings.

Validation on head `79a7d854b`, based on main `173ab9fa3`, with Rust
1.98.1 on macOS arm64 and the spill environment variable unset:

- `cargo fmt --all` and `cargo clippy --locked --all --tests --benches
-- -D warnings` pass.
- All 31 feature-flag tests pass in both debug and `release-with-debug`;
the public flag doctest also passes.
- Both recorded-move compaction cases with spilled lineage and all 56
debug spill tests pass, with no ignored tests.

Refs #9250; follows #9791 and #9886.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants