Repository navigation
feat(blob): reuse independently addressed managed objects - #9293
Conversation
westonpace
left a comment
There was a problem hiding this comment.
Next batch of questions, and one blocking concern around the "default managed base id"
| builder.push(BlobDescriptor::Managed { | ||
| base_id: base.id, | ||
| uri, | ||
| offset: if kind == BlobKind::Dedicated { | ||
| 0 | ||
| } else { | ||
| columns.positions.value(row) | ||
| }, | ||
| size: columns.sizes.value(row), | ||
| })?; |
There was a problem hiding this comment.
Does this convert existing packed / dedicated into managed?
There was a problem hiding this comment.
Yes. Compaction converts Packed/Dedicated descriptors to Managed references at their existing paths, without copying the payloads.
|
|
||
| /// Rewrite only top-level columns that contain selected references. Fragment | ||
| /// identity, row IDs, deletion vectors, and unrelated column files survive. | ||
| async fn rewrite_blob_columns( |
There was a problem hiding this comment.
Why are we doing this rewrite?
There was a problem hiding this comment.
Local blobs now keep the same relative paths, so their data files are copied unchanged. Only references to other bases need to be rewritten after copying those blobs into the destination.
There was a problem hiding this comment.
The portability concern is addressed: local Managed references follow table moves, shallow-clone compaction preserves the source base, and deep clones rebind registered references while preserving local descriptor files. Explicit bases must already be registered.
Before a Blob write or compaction activates Managed Blobs, upgrade or stop all older maintenance clients: cached or historical handles can still delete adopted sidecars despite the normal-open capability check.
The author-accepted cleanup cost remains: metadata-only histories may rescan unchanged Blob descriptors once per expired manifest. Draft #9435 tracks the separately reviewable deduplication; no further change is requested here.
Please mark this PR with the breaking-change label.
westonpace
left a comment
There was a problem hiding this comment.
Thanks for addressing the earlier review. The design looks good to me now!
Cleanup repeatedly scans Managed Blob descriptors when table versions share the same fragment view. This change records successful scans separately for retained and expired versions and adds discovered paths directly to the existing cleanup sets. Each view is scanned at most twice per cleanup, without retaining a separate copy of its full reference set. The scan identity includes fragment metadata (including deletions and overlays), projected fields and base bindings. It uses the implicit and registered base semantics from #9293. Branch retention shares the same inspection state; failed reads are never recorded as successful scans. A missing expired descriptor can be skipped, while a missing retained descriptor still stops cleanup before deletion. ## Benchmark Compared main `84d1681e07af565837f2d97e72ff1b8b040cd15c` with this PR at `9738f9ef767307f3e4695695b8d3915189d06f41`. Each case contains 100,000 real Managed objects. Metadata-only versions share two descriptor files; compaction cases replay cumulative appends followed by 8 or 32 compactions (24 or 96 table versions). The measured workflow is `dataset.cleanup(policy).with_max_candidate_files(0).explain()`, retaining the latest version and selecting older versions for cleanup. This measures inspection and file listing, without deleting files, so both versions use identical inputs. The 64-byte Dedicated payloads isolate descriptor work; cleanup does not read payload contents. Every latest payload was separately verified. One Apple M4 Max / 128 GiB / local APFS host, Rust 1.98.1, identical dependency lock and `release-with-debug` builds, eight CPU/I/O/runtime threads. Each version has an excluded warmup followed by five alternating pairs in fresh processes, with warm OS caches and no concurrent builds or dataset writes. Values below are medians; RSS includes dataset opening but excludes generation and payload validation. | Workload | Main inspection time | PR inspection time | Main peak RSS | PR peak RSS | |---|---:|---:|---:|---:| | 8 metadata-only versions | 1.456 s | 0.735 s | 215.8 MiB | 97.6 MiB | | 128 metadata-only versions | 15.089 s | 0.693 s | 373.6 MiB | 94.6 MiB | | 8 compactions | 1.911 s | 1.037 s | 223.2 MiB | 162.1 MiB | | 32 compactions | 6.046 s | 2.386 s | 272.4 MiB | 194.0 MiB | Median paired elapsed-time reductions are 49.6%, 95.4%, 45.8% and 60.5%, respectively. For 128 metadata-only versions, elapsed ranges are 14.553–15.469 s on main and 0.683–0.717 s on this PR. For 32 compactions they are 5.873–6.224 s and 2.319–2.493 s. These results cover local cleanup inspection, not S3 performance or the final deletion phase. Global path sets and metadata for distinct fragment views still consume memory. All paired cleanup removal statistics matched. Separate execution probes cover actual deletion, tagged and branched retention, dropped Blob columns and missing retained descriptors. Commands, all ranges, raw paired measurements, build hashes and dependency locks are preserved in the private benchmark project; the additional probes are standalone evidence, not new public CI coverage. The September S3 scan benchmarks in #9293 do not measure this change.
#9777) Managed Blob capability transitions and cleanup scan reuse need durable regression coverage after #9293 and #9435. These tests cover activation on new Blob files, preservation after removing Blob columns, coexistence with base-path and mixed-version flags, and cleanup retention across deletions, projections, tags, and branches. Concurrent scan requests must share one scan per retention class; failed descriptor reads must not publish successful completion or permit unsafe deletion. The cross-version tests use released v11.0.0 and v13.0.0 clients to create Packed/Dedicated data, verify metadata-only updates remain readable, and check that adoption and subsequent restore fence old opens and appends. Historical unflagged reads remain allowed; this does not promise safety for old cached-handle maintenance. Both release checks passed locally through the existing subprocess runner using ordinary CPython 3.14 for the released abi3 wheels. No production behavior changes. The larger Blob v2 specification remains in #9193.
The feature flag table still treats the Managed Blob bit as unknown, although #9293 assigned it. Express all bit masks as powers of two and document the Managed Blob capability at `2^14`, the unknown boundary at `2^15`, paired reader/writer bits, and activation and restore behavior, including the old-maintenance limitation. This corrects the flag reference for the implementation already on main. The full Blob v2 specification remains in #9193; this change does not add descriptor encodings or runtime behavior.
Blob v2's logical input, physical descriptors, object resolution, and lifetime rules are spread across the implementation and user guide. This spec brings those contracts together, distinguishing the table's logical schema from the data file's descriptor schema and defining ownership through rewrites, cleanup, and cloning. The spec reflects the Managed implementation merged in #9293 and the explicit opt-in added in #9891. Kind 4 uses the data file's implicit base; kind 5 carries a registered base ID. Ordinary writes retain Inline/Packed/Dedicated placement. Enabling `lance.blob.managed=true` activates the paired sticky capability flags and requires all maintenance clients to support Managed storage, including clients using cached or historical handles. This PR documents existing behavior and adds documentation links; it contains no runtime implementation changes. Closes #9014
Blob v2 compaction currently copies Packed and Dedicated payloads because their descriptors address sidecars through the containing data file. Managed descriptors carry a relative URI, byte range, and optional registered base ID, allowing compaction to preserve payload objects when replacing data files.
New payload objects use
_blobs/<uuid>.blob. Existing Packed and Dedicated objects can be adopted at their original paths without copying bytes, including when their original data files are later removed. Cleanup follows references from protected table versions. The default table base stays implicit, so moving the complete dataset does not retain its old URI. Shallow clone preserves the source base through existing data-file metadata. Deep clone copies local objects at the same relative paths without rewriting their descriptors; references to registered bases are copied and rebound into the destination.Managed uses the existing five descriptor fields in both file formats 2.2 and 2.3. Kind 4 uses the implicit table base; kind 5 carries an exact registered base ID, preserving IDs such as zero in existing shallow clones without changing descriptor nullability. Writer-side
base_id=Noneselects the implicit base. Explicit IDs must already exist; writes do not register bases automatically. New Blob data-file commits publish paired reader/writer table capability bits. The capability survives restore; metadata-only updates to an old table do not activate it. Existing kinds retain their read semantics. This adds no user configuration or repack API.Compatibility validation uses a checked-in v11.0.0 Packed/Dedicated fixture. The released v11.0.0 client refuses normal opens of flagged snapshots. A real cached-handle experiment also confirms the boundary: after new-client compaction and cleanup remove the original data files, old-client GC with
delete_unverified=Truecan still delete adopted sidecars, while leaving_blobsobjects alone. Before activation, upgrade all maintenance clients to a Managed-aware version or stop their maintenance tasks. All maintenance after activation must use a Managed-aware client; the flag blocks normal opens of flagged snapshots but cannot revoke pre-existing handles or retrofit old binaries' historical maintenance paths.Cleanup still rescans descriptors shared across metadata-only versions. Scan deduplication is deferred to #9435 for separate design review.
Regression coverage moves complete tables containing both new Managed objects and adopted released sidecars, removes the original location, then scans, reads, and runs cleanup at the new location. Clone coverage checks source retention after compaction, registered-base rebinding, and byte-for-byte preservation of local data files during deep clone. Prepared writes reject unknown bases, including nested Blob columns.
The format-spec proposal remains separate, as required by the repository's spec/implementation workflow.
Related: #8899 addresses the compaction problem through a Blob Reuse Index; #9193 documents the existing Blob v2 contract.
Benchmark
At the benchmarked revision, Managed kept total write amplification close to 1x through ten compactions, with approximately unchanged full-scan and random-read performance on the tested workloads.
Benchmarked revision:
f7dec16f659f758d2b7b302513501975767fda78; historical baseline:400408ffb7ee6b7bbf7c240962b5a94fb5fef879. Runs used one dedicated EC2 c7i.24xlarge (96 vCPUs, 192 GiB RAM) and same-region S3 in us-east-2, Rust 1.97.0,release-with-debugwith thin LTO, and 48 CPU/runtime threads. Both builds used identical dependency locks and CPU flags (haswell,+avx2,+fma,+f16c). Data uses deterministic high-entropy payloads in format 2.2. An explicit 8 KiB inline threshold and 512 KiB Dedicated threshold select the requested layouts; the production Dedicated default is 4 MiB.These measurements apply only to the pinned revision above. Subsequent changes include upstream BlobFile buffering/read changes, dependency updates, and portable Managed base resolution. The numbers have not been revalidated for the current head and are retained as historical evidence, not a current-head performance claim. Cleanup scan deduplication remains in draft follow-up #9435 and is outside these measurements.
Write amplification
For each payload size, append 10,000 rows at a time to 1,000,000 rows, compacting the accumulated table into one fragment after every additional 100,000 rows. No garbage collection runs. Total written bytes include appends, all ten compactions, descriptors and metadata; submitted write bytes were cross-checked against the retained S3 inventory. GB below is decimal.
Retained payload bytes equal logical input bytes for both cases: compaction did not rewrite the payloads. The historical full ingestion/compaction workflow was not measured, so these are candidate measurements, not a measured old/new write-amplification ratio.
Full-column scans
Read the entire blob column, including every payload and its checksum. Use 16 MiB logical batches, batch/fragment readahead 16, fresh processes, one excluded warmup per version, and three alternating old/new pairs, with no concurrent writes or other scans.
Both versions read identical 1M-row contents. The candidate uses its actual final compacted tables. Baseline final tables were generated directly with the old compaction writer's batch/row-group settings; a small preflight checked payload sizes, layout kinds and full contents against real old compaction output. This compares final-table reads and does not replay the old write workflow. Packed has 96 old versus 100 new payload objects; Dedicated has 1M in each version.
Random access: take 10 complete blobs
Reuse those same final tables. Each request selects ten distinct random row indices, calls
take_blobs_by_indices, and concurrently reads all tenBlobFilepayloads. Request batches are serial. Timing includes descriptor lookup, payload reads and checksum hashing; dataset open and expected-content generation are excluded. Each process reuses its dataset session, excludes ten warmup requests, then measures 100 requests. Five alternating pairs give 500 measured requests per version/layout, with matching random indices within each pair. Every returned payload and its row order were validated. This measures reused sessions; payload caches were not explicitly flushed.Latency percentiles use nearest-rank over the 500 requests. Paired changes use the median of within-pair new/old ratios (round P50s for random reads), not ratios of the aggregate table medians. Lower latency is better. These small differences do not establish a sustained read improvement or regression; results describe this configuration rather than a hardware throughput ceiling. Raw commands, checksums, timings, binary hashes and exact dependency locks are retained in the private benchmark project.