perf(dataset): serve read_version_transaction from the held or cached manifest - #33
Merged
summer-exa merged 1 commit intoSep 29, 2026
Conversation
… manifest `Dataset::read_version_transaction(version)` always resolved the version location and read + decoded the full manifest, even when the handle was already checked out at that version or the session cache held the manifest. On large datasets (orion.lance: ~4.8M fragments, ~1.2 GB manifests, 25-45 s from S3) that made every `read_transaction(version)` a full manifest download. Now: 1. version == self.manifest.version -> use the in-memory manifest and the same TransactionKey cache path as read_transaction(). 2. Otherwise resolve the location and, when the location carries a known size (hence a trustworthy e_tag), consult the shared ManifestKey cache before falling back to read_manifest. 3. Fallback path is unchanged (branch check, DatasetNotFound mapping). Assisted-by: devin:claude Co-Authored-By: summer <summer@exa.ai>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dataset::read_version_transaction(version)(→read_transaction_by_version→ PythonLanceDataset.read_transaction(version)) always didresolve_version_location+ a fullread_manifest(download + protobuf decode of the whole manifest) just to learntransaction_section/transaction_fileand the timestamp — even when the handle was already checked out atversionor the session cache held that manifest. Onorion.lance(~4.8M fragments) a manifest is ~1.2 GB and takes 25–45 s from S3, so the silk_node committer's idempotency window (checkout_version(latest)thenread_transaction(v)for each unseenv) paid a full manifest download per version.New branch order in
read_version_transaction:pub async fn read_version_transaction(&self, version: u64) -> Result<VersionTransaction> { + if version == self.manifest.version { + // in-memory manifest + same TransactionKey cache path as read_transaction() + return Ok(VersionTransaction { + version, + timestamp: self.manifest.timestamp(), + transaction: self.read_transaction().await?, + }); + } let manifest_location = self.commit_handler.resolve_version_location(..).await?; // LIST/HEAD, not the body - let manifest = read_manifest(&self.object_store, &manifest_location.path, manifest_location.size) - .await.map_err(NotFound -> DatasetNotFound)?; + let cached = if manifest_location.size.is_some() { // same guard as Dataset::get_manifest + self.metadata_cache.get_with_key(&ManifestKey { version, e_tag: manifest_location.e_tag.as_deref() }).await + } else { None }; + let manifest = match cached { + Some(m) => m, + None => Arc::new(read_manifest(..).await.map_err(NotFound -> DatasetNotFound)?), + }; // branch-mismatch check, read_transaction_from_storage, VersionTransaction { .. } — unchanged }resolve_version_location, noread_manifest. Reads/populates theTransactionKeycache exactly likeread_transaction(); the "no cache pollution" guarantee still holds for other versions.Dataset::get_manifest/checkout_versionpopulate the shared session cache underManifestKey { version, e_tag }, andresolve_version_locationreturns the sameversion/e_tag(a HEAD/LIST, not the body), so a cache hit gives the manifest and the location thatread_transaction_from_storageneeds. The lookup is guarded bymanifest_location.size.is_some(), mirroringget_manifest, so a location without size (no trustworthy e_tag) skips reuse rather than guessing. Onlyget_with_keyis used — no manifest is inserted for historical versions.DatasetNotFoundfor missing versions, timestamp from the manifest.read_transaction_by_versionandpython/src/dataset.rsare untouched — no signature change, no Python rebuild needed.Tests (
rust/lance/src/dataset/tests/dataset_transactions.rs)Manifests are inflated with a 256 KiB config value (
MANIFEST_PADDING_BYTES) so a full manifest read is distinguishable from a ranged transaction read. Because the local tracking store books a HEAD as aread_bytesof the full object size, cache-path assertions useranged_read_bytes(&IoStats)(sum ofIoRequestRecord.rangelengths, i.e. bytes actually transferred).test_read_version_transaction_same_version_skips_manifest_read(4 fragments, latest = v5):read_transaction()on a fresh handle (yardstick)read_bytes < 64 KiB,< manifest_sizeread_version_transaction(latest)read_iops == yardstick.read_iops,read_bytes == yardstick.read_bytes,read_bytes < 64 KiB,< manifest_size; result==read_transaction()and==fresh-openresultread_transaction()after the aboveread_iops == 0 && read_bytes == 0(TransactionKey cache populated)read_version_transaction(latest)(fallback)ranged_read_bytes > 256 KiB; result==same-version resultread_version_transaction(9999)Error::DatasetNotFoundcheckout_version(3)→read_version_transaction(3)read_bytes < 64 KiB;== read_transaction()read_version_transaction(latest)== latesttransaction/timestampSession, after the first handle checked out v3 →read_version_transaction(3)ranged_read_bytes <= 4 KiB(cached manifest reused)Session→read_version_transaction(3)ranged_read_bytes > 256 KiB(uncached, full read)test_read_version_transaction_external_transaction_fileextended: same-version read of a manifest withtransaction_file(no inline section) returns the transaction,read_iops >= 1(external file), and no request touches the manifest path.Verification
Rollout
not live until a fork release 9.0.1+exa.9 and a monorepo pin bump; neither is in this PR.
Link to Devin session: https://app.devin.ai/sessions/455f5722a6ff4f9bbe4cafaf06a4ab84
Open in Devin Desktop: https://app.devin.ai/desktop/session/455f5722a6ff4f9bbe4cafaf06a4ab84?variant=devin
Requested by: @summer-exa