Repository navigation
perf(cleanup): stop reading expired manifests when delete_unverified is set - #9764
Merged
jackye1995 merged 5 commits intoOct 24, 2026
Merged
Conversation
wjones127
self-requested a review
October 16, 2026 19:01
`list_manifests` reads `ObjectMeta`, which carries `last_modified`, then drops it converting to `ManifestLocation`. A caller that only needs a version's age has no choice but to read the whole manifest for `Manifest::timestamp`, which on a table with millions of versions means reading terabytes to answer a question the listing already answered. The field is the object write time, not the logical commit time, and the doc comment says so: rewriting an object by copy or migration moves one and not the other. It is `None` when the location came from somewhere that never saw an `ObjectMeta`, such as probing a known version or a namespace response. Same shape as carrying the manifest size instead of issuing a HEAD per manifest.
…is set Cleanup reads every manifest to split files into referenced (live) and verified (seen in a version being deleted). The verified set exists only to honour `delete_unverified=false`, which withholds deletion from files it cannot prove came from an expired version. When the caller sets `delete_unverified=true` they have said that proof is not required, so reading an expired manifest contributes nothing: its path, version, size and store identity all come from the listing. Retained manifests are still read, because the live set is what stops cleanup deleting live data. This is the whole cost on a table that accumulated versions faster than it cleaned them, where nearly every manifest is expired — the case where cleanup currently cannot finish at all. `proven_expired` answers "is this expired" from the listing alone and refuses to guess: a false means "not proven", never "retained", because misclassifying a retained manifest would delete live data. `before_timestamp` compares the object's write time, which is set after the commit time, so a write time before the cutoff proves the commit was too; the converse does not hold and falls back to reading. Skipping a read also loses that manifest's commit time, so the listing cutoff is dropped and the subtree is scanned in full. Missing a file would orphan it permanently; an extra listing only costs time. The tests are paired so neither can pass vacuously: one asserts no expired manifest is opened with the flag, the other asserts they all are without it.
jackye1995
force-pushed
the
jack/cleanup-skip-expired-reads
branch
from
October 23, 2026 19:13
5180f4a to
e8c62bb
Compare
wjones127
approved these changes
Oct 23, 2026
wjones127
left a comment
Contributor
There was a problem hiding this comment.
This seems like a worthwhile optimization. I noted a potential follow up that might save a lot in some situations.
Comment on lines
+2198
to
+2200
| /// Timestamp policies require reading the logical commit time: storage clocks and | ||
| /// timestamp precision do not guarantee that object write time is an upper bound. | ||
| /// All version conditions must be satisfied, and at least one must be specified. |
Contributor
There was a problem hiding this comment.
suggestion: it would be cool if once we found a manifest with a commit time before the timestamp cutoff, we could assume that all manifests with lower versions can also be excluded. This would require changing our commit logic to enforcing monotonically increasing timestamps so we don't get hit by clock skew.
Contributor
Author
This was referenced Oct 24, 2026
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.
When
delete_unverified=true, cleanup skips reading expired manifests selected bybefore_versionor explicitversions. Retained, tagged, and current manifests are still read to protect live files. This addresses the expired-manifest read amplification discussed in #9438 without adding an API.Timestamp policies always read the manifest's logical commit time. Storage write timestamps cannot prove expiry because their clocks and precision can differ from the writer's. Skipping any manifest read also disables the directory-listing time cutoff so cleanup still finds all expired files.
Rebased onto main and removed the unnecessary
ManifestLocation.last_modifiedchange, resolving the Rust CI compilation failures. Added regression coverage for timestamp precision and clock skew, alongside read-skipping and retention coverage. Local builds, tests, and clippy were omitted as requested; CI provides validation. Formatting passed.