Reduce locking and improve concurrency on cache hits - #124
Draft
mezz wants to merge 2 commits into
Draft
Conversation
|
mezz
marked this pull request as draft
August 4, 2026 07:35
this approach is similar to double-checked locking, we want to see if we can quickly use a cache hit before we do a full lock
mezz
force-pushed
the
pr/cache-hit-without-lock
branch
from
August 5, 2026 14:16
459ba75 to
032cc00
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.
Description
This PR skips the intermediate-result cache key lock on cache hits.
This approach is similar to double-checked locking, we want to see if we can quickly use a cache hit before we do a full lock. I wrote a big comment on it and a test to try to make the approach more clear.
Improvement
I am trying to speed up the case where I switch branches in my IDE, because I do that a lot when checking various bugs.
I found that this area seems to be one that takes the most time, even though everything is cached, and I think it's because many files are hitting this lock and causing it to be a serial process.
Tests
I added one test to try to replicate switching branches in my IDE. It caches one version of Minecraft, then switches to another, etc, to try to exercise the code and make sure it's not getting blocked on clear cache hits.
Notes
restoreOutputsFromCacheused to have a side-effect of creating the intermediate cache directory if it was missing.I don't know if it really matters, but I moved that to the
saveOutputspath instead, so that's always done in the locked section.