Repository navigation
Conversation
… 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>
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>
|
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>
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>
Co-Authored-By: Claude <noreply@anthropic.com>
|
@claude review |
…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
|
Heads-up for rebasing onto
Happy to take another look once this is rebased! |
|
@wjones127 addressed the comments, please take another look. Thanks! |
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>
|
@claude review |
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>
|
@claude review |
There was a problem hiding this comment.
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 withlance.zone_write_seeds.enabledgets 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 onesubmit_singleper 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 byseed_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 whencarry_v1_seedsis 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 withtry-binary-copyorforce-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) callsextract_source_seeds, which loops over everylance.seed.*key. Each pass awaits a separatefile_scheduler.submit_single(...)and fully decodes the buffer (seed_carry.rs:85-153).rewrite_files_binary_copyrepeats the same reads at binary_copy.rs:393. On a version 0 table, which is the default when onlyenabledis set,carry_v1_seedsis 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 everylance.seed.*metadata key. Each pass awaits its ownfile_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. Whencarry_v1_seedsis false, the bytes are thrown away byseed_acc.clear().
There was a problem hiding this comment.
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.
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 (legacyUpdateConfig/Overwriteand the composite action path), the same way thelance.auto_cleanup.*keys are.lance.zone_write_seeds.enabled"true"/"false"lance.zone_write_seeds.rows_per_zone1..=u32::MAXlance.zone_write_seeds.store_null_bitmap"true"/"false"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 thelance.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
rows_per_zonewhen there are several, and the indexes' null-bitmap policy). The dataset config does not change it.rows_per_zonewhen the setting is on. A ZoneMap index withuse_seeds = falsedoes not suppress it.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 withlance.zone_write_seeds.version = "1". Both can be set in oneupdate_config.rows_per_zoneapplies to later files; older files keep their records.index_rows_per_zonenow considers only indexes withuse_seeds = trueand takes their minimum; previously the last ZoneMap index of any kind won.store_null_bitmapis independent of the seed version: version 0 and version 1 seeds both record null positions when it is on. Withstore_null_bitmap = falsea configured seed records null counts only and serves ZoneMaps created withstore_null_bitmap = false. With the default it serves both kinds.Limitations
use_seedstakes the existing type-based default, which isfalsefor fixed-width types of 8 bytes or less (boolean, integers, floats, dates, times, timestamps, durations), so those columns needuse_seeds = trueon the index to reuse the seeds. This PR does not change that default; whether an unspecifieduse_seedsshould follow the table setting is left for a follow-up discussion.Tests
versionkey 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.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).use_seeds = falseindex.use_seedsreads no seeds and one built withuse_seeds = truereuses them.trueserve an index with and without a null bitmap;falsefalls back to a scan for a bitmap index.(use_seeds, rows_per_zone), unit tested (unseeded only, two seeded, seeded with unseeded).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 withrows_per_zone = 1,000,000.Append wall time relative to the setting off, 2% nulls at random positions:
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):
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:
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:
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:
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