-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add Better Peer Pruning #8501
Add Better Peer Pruning #8501
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #8501 +/- ##
===========================================
+ Coverage 58.09% 58.11% +0.01%
===========================================
Files 458 458
Lines 32823 32863 +40
===========================================
+ Hits 19070 19099 +29
- Misses 10859 10872 +13
+ Partials 2894 2892 -2 |
beacon-chain/cache/subnet_ids.go
Outdated
s.aggregatorLock.Lock() | ||
defer s.aggregatorLock.Unlock() | ||
s.subnetsLock.Lock() | ||
defer s.subnetsLock.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be safer if we don't obtain several locks for the same operation, but have 3 inline function calls:
go func() {
s.attesterLock.Lock()
defer s.attesterLock.Unlock()
s.attester.Purge()
}()
Those calls can be blocking/sequential, of course:
// obtain lock1
// clear cache
// release lock1
// obtain lock2..
Whenever function obtains two locks I feel uneasy, worrying about whether there's some part of the code that holds the second lock, and in a race for the first lock of the function (thus, potentially, resulting in a deadlock).
Since this method is to be used for tests only, it is probably an overkill to worry about such things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, even though its a test only function, should still fix it. Patching it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, approved (if you want to follow the suggestion on multiple locks, will re-approve after the code is updated -- but it is not strictly necessary, so feel free to merge as is).
What type of PR is this?
Feature Improvement
What does this PR do? Why is it needed?
function better.
Which issues(s) does this PR fix?
N.A
Other notes for review