Skip to content

Renew stale leases of files that CreateDigest stores again - #23750

Merged
jgranstrom merged 1 commit into
mainfrom
jg/renew-existing-bytes
Nov 5, 2026
Merged

jgranstrom merged 1 commit into
mainfrom
jg/renew-existing-bytes

Conversation

@jgranstrom

Copy link
Copy Markdown
Contributor

ShardedLmdb::store_bytes_batch skips writing leases for content already stored. CreateDigest stores 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 only CreateDigest calls, 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_stale decides 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 from renew_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

@jgranstrom
jgranstrom marked this pull request as ready for review November 3, 2026 20:28
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
jgranstrom force-pushed the jg/renew-existing-bytes branch from e6b65a5 to 8c5f274 Compare November 5, 2026 20:14
@jgranstrom
jgranstrom merged commit d99d311 into main Nov 5, 2026
28 checks passed
@jgranstrom
jgranstrom deleted the jg/renew-existing-bytes branch November 5, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants