-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace util.SyncStore implementation to use singleflight and sync.Map. #5016
Merged
Conversation
This file contains 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
…nce for every artifact
Codecov Report
@@ Coverage Diff @@
## master #5016 +/- ##
==========================================
+ Coverage 72.15% 72.16% +0.01%
==========================================
Files 365 365
Lines 12807 12837 +30
==========================================
+ Hits 9241 9264 +23
- Misses 2879 2884 +5
- Partials 687 689 +2
Continue to review full report at Codecov.
|
gsquared94
reviewed
Nov 11, 2020
gsquared94
reviewed
Nov 11, 2020
gsquared94
reviewed
Nov 11, 2020
gsquared94
approved these changes
Nov 13, 2020
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.
This is follow up of #4896
In #4896, I used a library
sync/singleflight
to make suregetDependencies
results were cached and only computed once for dockerfile builder.sync/singleflight
ensure same function for given input key executes only once across multiple goroutines at a given time. Along withsync.Map
, we can make sure at any given time, the function for given input key only executes once across multiple subroutines.This is ensured by, wrapping the result of the function we want to execute and storing it in a thread safe
sync.Map
For cache miss, execute the func and store the result.
During review @gsquared94 mentioned, he added
util.Store
which usessync.Once
andsync.Map
to achieve th same thing.sync/singleflight
is safer for a corner case when same key is looked up exactly at the same point in different subroutines.Hence replacing the
sync.Store
implementation withsync/singleflight
No User facing changes