Skip to content

ReusableOptimizer: don't overwrite better paths from other processes - #92

Merged
jcmgray merged 1 commit into
mainfrom
reusable-improved-reread
Nov 9, 2026
Merged

jcmgray merged 1 commit into
mainfrom
reusable-improved-reread

Conversation

@jcmgray

@jcmgray jcmgray commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Follow up to #90, from the comment on #89.

With overwrite="improved", ReusableOptimizer compared new paths against its own in-memory copy of the cache entry, never the disk. With several processes sharing a cache directory, one process could replace a better path written by another with a worse one. update_from_tree (which defaults to "improved") had the same problem.

Changes:

  • DiskDict.get has a new refresh=False option, to read from disk even if the key is in memory. If the disk read fails, it falls back to the memory copy.
  • ReusableOptimizer uses it just before the "improved" comparison, in both _maybe_run_optimizer (after the optimizer run) and update_from_tree. overwrite=False and overwrite=True are unchanged.

The extra read costs about 10–20 µs on a local disk, compared with ms to seconds for the optimizer run that "improved" mode already does on every call.

@jcmgray
jcmgray merged commit 5d3558c into main Nov 9, 2026
18 checks passed
@jcmgray
jcmgray deleted the reusable-improved-reread branch November 10, 2026 17:20
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.

1 participant