Skip to content

Replace a local process cache entry whose outputs are gone - #23749

Merged
jgranstrom merged 1 commit into
mainfrom
jg/process-cache-overwrite
Nov 5, 2026
Merged

jgranstrom merged 1 commit into
mainfrom
jg/process-cache-overwrite

Conversation

@jgranstrom

Copy link
Copy Markdown
Contributor

PersistentCache::store writes with NO_OVERWRITE. Once GC deletes a cache entry's outputs, the process re-runs, but its result can't replace the old entry. A process whose outputs differ per run (sandbox paths, mtimes) then re-runs on every run. I.e. it re-runs, writes new cached content, but the cache entry is not updated so next time it re-runs again, forever for the same process inputs.

PersistentCache::store now writes through a new ShardedLmdb::overwrite_bytes, which replaces the existing value. Content writes (store_bytes, store_bytes_batch) keep NO_OVERWRITE. A cache hit writes nothing, so an entry is only replaced after its process actually re-ran.

On a BSP compile of a large Scala project, repeat compiles went from 43 s to 9 s.

Disclosure: Implemented and verified with Claude with human direction

@jgranstrom
jgranstrom marked this pull request as ready for review November 3, 2026 20:28
PersistentCache::store wrote with NO_OVERWRITE, so an entry whose outputs
garbage collection had deleted was never replaced. A process whose outputs
differ per run then re-ran on every later run and its result was dropped.
It now writes through ShardedLmdb::overwrite_bytes, which replaces the
existing value.
@jgranstrom
jgranstrom force-pushed the jg/process-cache-overwrite branch from 6067bb2 to 54cd7b8 Compare November 5, 2026 19:33
@jgranstrom
jgranstrom merged commit bd199b5 into main Nov 5, 2026
28 checks passed
@jgranstrom
jgranstrom deleted the jg/process-cache-overwrite branch November 5, 2026 20:06
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