Repository navigation
Renew stale leases of files that CreateDigest stores again - #23750
Merged
Merged
Conversation
jgranstrom
marked this pull request as ready for review
November 3, 2026 20:28
benjyw
approved these changes
Nov 4, 2026
store_bytes_batch skips the lease of content that is already stored, so CreateDigest's files keep the lease of their first write. pantsd's lease pass does not see them, so GC can delete them while they are in use. Store::store_file_bytes_batch, which only CreateDigest calls, now renews the lease of an already stored small file when it is missing or has at most half the lease time left, in the same write transaction. ShardedLmdb::lease decides staleness through the same function.
jgranstrom
force-pushed
the
jg/renew-existing-bytes
branch
from
November 5, 2026 20:14
e6b65a5 to
8c5f274
Compare
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.
ShardedLmdb::store_bytes_batchskips writing leases for content already stored.CreateDigeststores the same files on every run, so they keep their lease of their first ever write. The lease extension does not cover them, as they are rule results not a node output. GC can delete them while being actively in-use.With this PR
Store::store_file_bytes_batch, which onlyCreateDigestcalls, now renews the lease of an already stored file under 512 KiB when it is missing or has at most half its time left, in the write transaction the batch already opens. Other writes are unchanged.ShardedLmdb::lease_is_staledecides staleness in the caller's transaction.lease_outlasts(Make idle pantsd lease extension cheap #23739) now calls it, and both take the half-lease threshold fromrenew_before.On an 18,000-process build that creates 5,758 files per run, this costs about 9 ms per run, and 0.08 s on a run after an idle hour.
This does not cover files of 512 KiB or more, they are leased by mtime. And CreateDigest results that are kept memoized until they become old enough to become GCed (generally quite a long time since they now get leased when the rule runs if old).
Disclosure: Implemented and verified with Claude with human direction