Skip to content

feat: collect zone map write seeds for unindexed columns from dataset config - #11373

Open
LuQQiu wants to merge 24 commits into
lance-format:mainfrom
LuQQiu:lu/zone-write-seeds-config
Open

LuQQiu wants to merge 24 commits into
lance-format:mainfrom
LuQQiu:lu/zone-write-seeds-config

Conversation

@LuQQiu

@LuQQiu LuQQiu commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Zone map write seeds are collected today only for columns that already have a ZoneMap index with use_seeds = true. Data written before such an index exists carries no seed, so the first index build (and every build over older fragments) scans the column.

This PR adds a dataset-level switch so that writes embed seeds for scalar columns that have no seeded ZoneMap index yet. A ZoneMap built later on such a column reuses the seeds instead of scanning.

Dataset config

Set with Dataset::update_config; all three are validated in the commit that sets them (legacy UpdateConfig / Overwrite and the composite action path), the same way the lance.auto_cleanup.* keys are.

Key Values Absent
lance.zone_write_seeds.enabled "true" / "false" off
lance.zone_write_seeds.rows_per_zone integer in 1..=u32::MAX 8192
lance.zone_write_seeds.store_null_bitmap "true" / "false" true

These keys only choose which columns are seeded. The seed format is governed separately by lance.zone_write_seeds.version (#11433), which is accepted and validated alongside them. Other keys under the lance.zone_write_seeds. prefix are left alone, so a setting added by a later release does not block changes made with this one. A value already present in a manifest written by a build without validation is read leniently (warning and default). The four keys are listed in the table config spec (docs/src/format/table/table_config.md).

Behaviour

  • A column with a usable ZoneMap index that requests seeds keeps today's rule: the seed follows the index (the smallest rows_per_zone when there are several, and the indexes' null-bitmap policy). The dataset config does not change it.
  • Any other top-level column of a supported type gets a seed sized by rows_per_zone when the setting is on. A ZoneMap index with use_seeds = false does not suppress it.
  • Supported types: boolean, integers, floats, decimals, date, time, timestamp, duration, string and binary (variable-length, including the large variants, and fixed-size). Not seeded from the config: nested types and vectors, dictionary, blob columns and extension-typed columns.
  • Enabling the setting never sets FLAG_ZONE_WRITE_SEEDS. Configured seeds use the same format version as index-requested seeds: version 0 by default, readable by older releases, and version 1 only on a table that has opted in with lance.zone_write_seeds.version = "1". Both can be set in one update_config.
  • Writes based on a version from before the setting was enabled stay unseeded.
  • Disabling stops collection for later writes; existing seeds stay. Changing rows_per_zone applies to later files; older files keep their records.
  • Binary-copy compaction keeps the version 1 gate from fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default #11433: version 1 seeds are carried, version 0 seeds are dropped and no flag is set. For carried seeds the declared zone size of the output follows the same precedence (seeded index, else the config, else the writer default). index_rows_per_zone now considers only indexes with use_seeds = true and takes their minimum; previously the last ZoneMap index of any kind won.
  • store_null_bitmap is independent of the seed version: version 0 and version 1 seeds both record null positions when it is on. With store_null_bitmap = false a configured seed records null counts only and serves ZoneMaps created with store_null_bitmap = false. With the default it serves both kinds.

Limitations

  • The write that creates a dataset is not seeded: the setting lives in the dataset config, which the creating write does not have yet. Create, set the config, then append. Seeding the creating write is left to a follow-up.
  • Overwrite does not collect seeds (unchanged).
  • An index build reads configured seeds only when the index uses seeds. An index created without an explicit use_seeds takes the existing type-based default, which is false for fixed-width types of 8 bytes or less (boolean, integers, floats, dates, times, timestamps, durations), so those columns need use_seeds = true on the index to reuse the seeds. This PR does not change that default; whether an unspecified use_seeds should follow the table setting is left for a follow-up discussion.
  • Only top-level columns are covered; fields nested in a struct are not.
  • Binary-copy compaction reads each seed of each input file with a separate request, once for the eligibility check and once for the rewrite. With the setting on, every supported column of every file carries a seed, so this can be slow on wide tables on object storage. End-to-end latency for that case has not been measured. Compaction that re-encodes data does not read seeds this way.
  • On a table that has not opted into version 1, configured seeds do not survive binary-copy compaction, and version 0 seeds of float zones that contain NaN are not reused by an index build (both as for index-requested seeds).

Tests

  • Config parsing and mutation-time validation on both commit paths, including an unknown key under the prefix that is kept and does not block later changes, the version key together with the three collection keys in one update, an invalid intermediate value repaired within one composite and an inherited invalid value with an unrelated update.
  • Seeds on unindexed columns at both versions: enabled alone leaves the flag unset and writes version 0 seeds; enabled with version = "1" sets the flag and writes version 1 seeds. Vector and struct columns stay unseeded. The seed version follows the table across appends (0, then 1, then pinned back to 0). Lifecycle (enable, disable, resize, reopen).
  • Precedence between a seeded index and the config; a use_seeds = false index.
  • The type-based default is pinned: on an Int64 column with configured seeds, an index built without use_seeds reads no seeds and one built with use_seeds = true reuses them.
  • Round trip per type (seed written, index built from the seed, filters equal to an unindexed scan) for 18 types, on a version 1 table.
  • Zone boundaries (Int64 with nulls): seed and index zone sizes that are equal, nested, non-dividing (8 into 20) and coarser-than-index, with fragment sizes that do and do not divide the zone and writer batches that straddle zones; plus a seed size that does not divide the index zone (8 into 1,004) and equal sizes with a short final zone, on fragments neither size divides, and 8192-row zones on a 20,000-row fragment. Each case asserts the exact reuse report (records reused, fragments and rows scanned), every stored zone's span, null count, min and max against values derived from the generator, and query results against an unindexed scan.
  • The same stored-statistics check, on a version 1 table, for 32 type variants (all integer widths, Float16/32/64, both date types, time and timestamp units, durations, strings, binaries, Decimal128/256), each with an index that keeps a null bitmap and one that does not, at a shape that mixes reused and scanned zones. These are representatives of each admitted type family, not every timezone or precision/scale parameterization.
  • Null positions: default and explicit true serve an index with and without a null bitmap; false falls back to a scan for a bitmap index.
  • The zone size binary-copy compaction declares for a column is a pure function of its indexes' (use_seeds, rows_per_zone), unit tested (unseeded only, two seeded, seeded with unseeded).
  • Binary-copy compaction: on a version 1 table, inputs with different seed sizes are carried and fully reused; on a version 0 table the seeds are dropped and the flag stays unset.

Measurements

Taken before #11433, when enabling the setting also selected version 1 seeds, so every arm below wrote version 1 seeds. They were not repeated for version 0.

Single-column tables, 100M rows appended in one call to local NVMe (1M rows per file), same binary and identical pre-generated data for every arm, 3 repetitions, median. aarch64, 16 cores. Index: ZoneMap with rows_per_zone = 1,000,000.

Append wall time relative to the setting off, 2% nulls at random positions:

Type off (s) on, no null positions on, null positions Index build, scan → from seeds (s)
int32 0.46 +54% +113% 0.40 → 0.008
int64 0.54 +40% +88% 0.41 → 0.008
float32 0.52 +88% +140% 0.41 → 0.009
float64 0.70 +68% +104% 0.45 → 0.008
date32 0.42 +58% +121% 0.39 → 0.008
timestamp (ms) 1.09 +20% +44% 0.40 → 0.008
boolean 0.26 +254% +352% 0.46 → 0.008
decimal128 1.07 +28% +54% 0.52 → 0.008
utf8, 16 chars 9.97 +6% +9% 0.69 → 0.010
binary, 64 bytes 7.90 +6% +11% 1.33 → 0.012
utf8, 256 chars (7.9M rows) 9.98 +1% +1% 1.82 → 0.030

The absolute cost for narrow types is 2 to 7 ns per row; the percentage is high because writing a narrow column to local disk is itself very cheap. Seed size 8192 instead of 1,000,000 adds a few percentage points.

Null positions, int64, by null fraction (random positions; clustered nulls are in the next section):

Nulls on, no null positions on, null positions Extra bytes per 1M-row file with positions
0% +56% +55% 2 KB
2% +40% +88% 162 KB
30% +100% +351% 526 KB

A ZoneMap that stores a null bitmap builds from seeds with positions in 0.034 s (2% nulls) and 0.084 s (30%) instead of 0.41 s and 0.47 s by scan; seeds without positions cannot serve it. Peak RSS (one observation per arm) showed no clear difference. Every arm verified the committed config, both feature-flag words and the presence of seeds in the appended files before timing, and compared filtered counts with and without the index afterwards.

Object storage, version 0 and clustered nulls

A second run with one binary built from this branch, first on local NVMe and then on S3 in the same region. Same shape as above (single column, 100M rows appended in one call, 100 files, 3 repetitions, median, 16 cores). The dataset is reopened before every index build, so no build benefits from file metadata cached by an earlier one. All 162 runs passed the seed presence and filtered-count checks.

Append wall time relative to the setting off, version 1 seeds, 2% nulls at random positions:

Type Local off (s) Local, no null positions Local, null positions S3 off (s) S3, no null positions S3, null positions
int64 0.58 +36% +86% 8.03 +9% +16%
boolean 0.27 +247% +347% 4.76 +16% +12%
timestamp (ms) 1.25 +17% +37% 24.71 -2% -1%
utf8, 16 chars 10.18 +6% +8% 35.90 0% +4%

The extra CPU time is the same on both (0.2 to 1.1 s per 100M rows); on S3 the upload dominates. Repetitions of one S3 arm differ by 10% or more, so differences of a few percent there, including the negative ones, are noise.

Index build, scan → from seeds (s), version 1:

Type Local S3
int64 0.42 → 0.009 1.00 → 0.62
boolean 0.49 → 0.009 0.98 → 0.66
timestamp (ms) 0.42 → 0.008 1.18 → 0.66
utf8, 16 chars 0.72 → 0.011 1.97 → 0.67

On S3 a build from seeds takes about 0.6 s for 100 files whatever the type; it reads no column data, where the scan reads the whole column. The time saved is therefore 1.3x to 3x at this size, not the 50x seen on local disk. Bytes read, larger file counts and wide columns were not measured.

Version 0 seeds (table without the version 1 opt-in), local: int64 matches version 1 (+37% / +88% append, 0.42 → 0.008 s build). float64 pays the append cost (+68% / +103%) but its seeds are not reused (0.47 s by scan, 0.47 s from seeds), because the generated data contains NaN and version 0 cannot describe such zones. On S3 the append difference for both types is within noise (-3% to +6%).

Clustered nulls (int64, version 1, runs of 1000 consecutive nulls), local, null positions recorded:

Nulls Positions Append Extra bytes per 1M-row file Bitmap index from seeds (s)
2% random +86% 159 KB 0.035
2% clustered +36% 3 KB 0.008
30% random +329% 514 KB 0.090
30% clustered +38% 7 KB 0.010

With clustered nulls, recording positions costs about the same as not recording them; random positions are the worst case. On S3 the clustered cases add 5% to 6% to the append.

🤖 Generated with Claude Code

… config

Add two dataset config keys. `lance.zone_write_seeds.enabled` makes writes
embed a zone map seed for every top-level column of a supported scalar type
that no seeded ZoneMap index covers, so a ZoneMap index created later can be
built from seeds instead of scanning. `lance.zone_write_seeds.rows_per_zone`
sets the rows per seed zone for those columns (default 8192). A column with a
seeded ZoneMap index keeps following that index. The commit that enables the
setting also sets the seed feature flags; binary-copy compaction declares the
same zone size for carried seeds.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 23, 2026
Reject an invalid lance.zone_write_seeds.* value in the commit that sets it,
as the auto-cleanup keys are validated, instead of falling back on later
writes. Add lifecycle, per-type round-trip and binary-copy carry tests.

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

LuQQiu and others added 15 commits November 22, 2026 18:00
Zone statistics have no min/max for fixed-size binary, so a seed for such a
column is always rejected by the index build. Also check unseeded nested
columns in the test through every file of the fragment.

Co-Authored-By: Claude <noreply@anthropic.com>
Check the final manifest once after all actions, as the auto-cleanup settings
are checked. Assert seed reuse in the binary-copy carry test and add value
predicates to the per-type round trip.

Co-Authored-By: Claude <noreply@anthropic.com>
A Lance field stores view types as their base string or binary type, so the
case asserted on a type the gate never sees.

Co-Authored-By: Claude <noreply@anthropic.com>
Add lance.zone_write_seeds.store_null_bitmap (default true) so seeds collected
from the dataset config can serve a zone map that stores a null bitmap.

Co-Authored-By: Claude <noreply@anthropic.com>
Adds a matrix over seed size, index size, fragment length and batch size
that checks which fragments are reused, partly scanned or scanned, and
compares indexed results row by row with the generator and an unindexed
scan.

Co-Authored-By: Claude <noreply@anthropic.com>
A partly reused fragment is reported as both partial and scanned, and
scanned rows include the unseeded creating fragment. Corrects the
expectation for 8-row records over 20-row index zones.

Co-Authored-By: Claude <noreply@anthropic.com>
Asserts the exact outcome for a seed coarser than the index and adds
8192 and 1,000,000-row zone sizes over a fragment length neither divides.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Reads every persisted zone of the index built from configured seeds and
checks its span, bounds and null count against values computed from the
generator, including the unseeded creating fragment and short final zones.

Co-Authored-By: Claude <noreply@anthropic.com>
…ndex

Checks reuse, stored zone statistics and query results for integer,
float, string, timestamp, boolean and decimal columns where reused and
scanned zones mix.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@LuQQiu
LuQQiu marked this pull request as ready for review November 24, 2026 04:38
@LuQQiu

LuQQiu commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@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 pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

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

Code review found no issues

No high-confidence issues detected in this change.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 24, 2026
Xuanwo added a commit that referenced this pull request Nov 24, 2026
…v0 writes by default (#11433)

## Summary

Fixes a cross-version compatibility break introduced by #10102 before
releasing Lance v15.0.0.

### Problem

Since Lance v10 (#7427), `ZoneMap` indices on string, binary, decimal,
fixed-size binary (>8 bytes), and nested columns default to `use_seeds =
true`. In #10102, any commit on a dataset carrying a `use_seeds = true`
ZoneMap index automatically set `FLAG_ZONE_WRITE_SEEDS` (`1 << 16`) in
both `reader_feature_flags` and `writer_feature_flags`.

Because `v14.0.0` reserves bit 16 as unsupported and `v15.0.0` is the
first stable release able to read it, automatic activation breaks
rolling upgrades: a single v15 writer performing any normal commit
(`Append`, `Update`, `Delete`, `DataReplacement`, `Compact`, etc.)
permanently (sticky bit) locks out all Lance `< 15` readers with no
rollout window. This also diverged from the zone write seeds format spec
(#9564, `docs/src/format/index/scalar/zone_write_seeds.md`, *"Activation
is explicit, not triggered by opening a table"*) and from every other
v15 reader feature flag (`FLAG_MANAGED_BLOBS`,
`FLAG_SPILLED_ROW_LINEAGE`, `FLAG_INLINE_DELETIONS`), all of which
require explicit opt-in.

### Changes

- **Remove automatic activation**: Remove `apply_seed_feature_flags`
from the commit path (`rust/lance/src/io/commit.rs`,
`rust/lance/src/dataset/write/seeds.rs`). Normal commits and
`CreateIndex` no longer set `FLAG_ZONE_WRITE_SEEDS`.
- **Add explicit opt-in config**: Add dataset config key
`lance.zone_write_seeds.version` (valid values `"0"` and `"1"`)
validated when modified on both legacy (`UpdateConfig`, `Overwrite`) and
composite transaction paths (`rust/lance-table/src/feature_flags.rs`,
`rust/lance-table/src/transaction/`).
- Absent or `"0"`: `FLAG_ZONE_WRITE_SEEDS` stays unset; writers emit v0
seeds.
- `"1"`: Atomically sets `FLAG_ZONE_WRITE_SEEDS` in both
`reader_feature_flags` and `writer_feature_flags`. Once set, the flag
remains sticky across subsequent commits, index drops, restores, and
clones; setting `"0"` pins future writes back to v0 while keeping the
flag sticky.
- Designed to live in the same `lance.zone_write_seeds.*` namespace as
#11373.
- **Keep v0 write seeds by default**: Add `ZoneMapSeedVersion::{V0, V1}`
to `ZoneMapSeedWriter` (`rust/lance-index/src/scalar/zonemap.rs`).
Tables that have not activated `FLAG_ZONE_WRITE_SEEDS` (or are pinned to
`"0"`) emit v0 seeds (no `version` metadata, no `negative_nan_count`,
`max = +NaN` when `nan_count > 0`, `required_feature_flags() == 0`).
This preserves Lance `< 15` read/write compatibility **without**
regressing `optimize_indices` performance (since #10165 already reuses
v0 seeds with `nan_count == 0`, covering all non-float and NaN-free
float zones).
- **Binary-copy compaction**: Carry v1 seeds when
`write_v1_zone_write_seeds` is true; otherwise drop v0 seeds cleanly
without activating `FLAG_ZONE_WRITE_SEEDS`
(`rust/lance/src/dataset/optimize/binary_copy.rs`).
- **Tests**:
- Updated and expanded unit/integration tests across `lance-table`,
`lance-index`, and `lance` covering v0 default writes, explicit v1
opt-in, sticky flag behavior, config validation, binary-copy compaction,
and external scalar plugins.
- Extended `ZonemapBloomfilterIndex` in
`python/python/tests/compat/test_scalar_indices.py` with a string column
(which defaults to `use_seeds=True` on Lance >= 10) so the compat matrix
catches write-seed regressions going forward.

## Verification

- `cargo test --profile ci -p lance-table --lib --doc`
- `cargo test --profile ci -p lance-index --lib zonemap`
- `cargo test --profile ci -p lance --lib -- seed` / `binary_copy` /
`zone_map`
- `cargo test --profile ci -p lance --test external_scalar_plugin`
- `cargo fmt --all -- --check` & `cargo clippy --profile ci --all
--tests --benches -- -D warnings`
- `cd python && uv run make lint` (ruff, pyright, cargo fmt, cargo
clippy)
- Smoke-tested `ZonemapBloomfilterIndex` locally against the built
`pylance` wheel
@Xuanwo

Xuanwo commented Nov 24, 2026

Copy link
Copy Markdown
Member

Heads-up for rebasing onto main: #11433 just merged to keep FLAG_ZONE_WRITE_SEEDS explicit opt-in for v15 rolling upgrades (avoiding silently locking out Lance < 15 readers on existing seeded ZoneMap tables). A few overlap points with this PR:

  1. Config prefix validation: fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default #11433 added lance.zone_write_seeds.version ("0" / "1", ZONE_WRITE_SEEDS_VERSION_KEY). validate_zone_write_seeds_config will need to allow this key under lance.zone_write_seeds. alongside enabled, rows_per_zone, and store_null_bitmap.
  2. Explicit FLAG_ZONE_WRITE_SEEDS activation: fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default #11433 removed apply_seed_feature_flags from the commit path; FLAG_ZONE_WRITE_SEEDS is now activated only when a commit explicitly writes lance.zone_write_seeds.version = "1" (apply_zone_write_seeds_version_config), while unactivated tables emit v0 seeds (ZoneMapSeedVersion::V0) via write_v1_zone_write_seeds(manifest). Unindexed seed writers created from lance.zone_write_seeds.enabled = "true" can follow the same zone_map_seed_version so v15 writes stay < 15-compatible by default until version = "1" is opted in.
  3. Binary-copy seed carry: fix(index): require explicit opt-in for v1 zone write seeds and keep v0 writes by default #11433 gated seed_acc.finish(...) on write_v1_zone_write_seeds(&dataset.manifest) so v0 seeds are dropped without setting FLAG_ZONE_WRITE_SEEDS; unindexed_rows_per_zone can stay inside that same gate.

Happy to take another look once this is rebased!

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 24, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
@LuQQiu

LuQQiu commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@wjones127 addressed the comments, please take another look. Thanks!

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 2, 2026
Zone statistics now compute min/max bounds for fixed-size binary
values, so a seed for such a column can be reused by an index build.

Co-Authored-By: Claude <noreply@anthropic.com>
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
@LuQQiu

LuQQiu commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 2, 2026

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

Findings marked 🟡 are optional suggestions and need no follow-up push.

Comment thread rust/lance/src/dataset/write/seeds.rs Resolved
Comment thread rust/lance/src/dataset/write/seeds.rs Resolved
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Dec 2, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Dec 2, 2026
An index created without an explicit use_seeds takes the type-based
default, which is false for fixed-width types of 8 bytes or less, so
those columns need use_seeds=true to reuse configured seeds. Add a test
that pins this, use "indices" in the new code and docs, and shrink the
two million-row boundary cases to the same geometry at small sizes.

Co-Authored-By: Claude <noreply@anthropic.com>
@LuQQiu

LuQQiu commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@lance-gatekeeper lance-gatekeeper Bot removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Dec 2, 2026

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🟡 rust/lance-table-runtime/src/optimize/binary_copy.rs — Binary-copy compaction on tables with lance.zone_write_seeds.enabled gets much slower. Every input file now has one seed per scalar column, and each is read one request at a time, twice. extract_source_seeds (seed_carry.rs:134) awaits one submit_single per seed. It runs in the gate (execution.rs:230) and again at binary_copy.rs:393. On version 0 tables those seeds are then thrown away by seed_acc.clear(). Fix: read all of a file's seed buffers in one batched request, or reuse the tail read. Also skip the second read when carry_v1_seeds is false, since the gate has already checked the buffers.

    Why this was flagged

    Trigger: a table sets lance.zone_write_seeds.enabled=true, receives many small appends, then runs compaction with try-binary-copy or force-binary-copy. Writes now attach a seed to every supported top-level column (seeds.rs:251-264). On the base branch only columns with a seeded ZoneMap index got one. can_use_binary_copy_current (execution.rs:229-242) calls extract_source_seeds, which loops over every lance.seed.* key. Each pass awaits a separate file_scheduler.submit_single(...) and fully decodes the buffer (seed_carry.rs:85-153). rewrite_files_binary_copy repeats the same reads at binary_copy.rs:393. On a version 0 table, which is the default when only enabled is set, carry_v1_seeds is false and the bytes are dropped at binary_copy.rs:401. So a 100-column table compacting 500 small files issues about 100,000 extra sequential small object-store GETs. The gate exists to check that buffers are safe, not to keep the work cheap.

    Verification: extract_source_seeds (seed_carry.rs:85-136) loops over every lance.seed.* metadata key. Each pass awaits its own file_scheduler.submit_single(...), so a file's seeds are read one after another. The function runs once in the gate (execution.rs:229-235) and again at binary_copy.rs:393. When carry_v1_seeds is false, the bytes are thrown away by seed_acc.clear().

@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 with a non-blocking risk.

The narrow-column concern is addressed in the configuration and module docs: set use_seeds=true explicitly on those indices to reuse collected seeds. The new default/reuse test and all three boundary cases passed locally. Collection remains opt-in, preserves seeded-index precedence and unknown settings, and retains explicit v1 activation. The v0 limitations remain documented: binary copy drops its seeds, and NaN-bearing float zones fall back to scanning.

The remaining binary-copy performance risk affects wide tables on object storage. Above the small-file cache threshold, eligibility checking and rewriting each read seeds serially, including v0 seeds that are then discarded. An isolated extractor check confirmed 200 range reads for 100 seeds across two passes, even with retained buffers; end-to-end cloud latency remains unmeasured. reencode compaction avoids that request pattern at the cost of re-encoding.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-format On-disk format: protos and format spec docs enhancement New feature or request format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants