-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Optimize fixedsize reservoir #7447
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
base: main
Are you sure you want to change the base?
Optimize fixedsize reservoir #7447
Conversation
bf5b8be to
7705d99
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7447 +/- ##
=====================================
Coverage 86.2% 86.2%
=====================================
Files 302 302
Lines 21991 22002 +11
=====================================
+ Hits 18968 18980 +12
+ Misses 2642 2641 -1
Partials 381 381
🚀 New features to boost your workflow:
|
906bb67 to
a894b33
Compare
5daf244 to
cb4d407
Compare
| r.wMu.Lock() | ||
| defer r.wMu.Unlock() | ||
| r.advance() |
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.
Should the lock be held here? Why not within advance? This seems very prone to deadlocks.
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.
We don't hold the lock within advance because we also call advance() from within reset(), which needs to hold the lock for all operations.
It shouldn't be prone to deadlocks because both locations where we acquire the lock (reset() and Offer()) don't block on anything else while they hold the lock.
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.
Missing test cases for when k is 0 and greater than math.Maxuint32.
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.
Added a test for k < 0. I tried to add a test case for greater than maxuint32, but I can't allocate a slice that large on my computer. I could use a bunch of mocks and such to test the if statement, but i'm pretty sure it isn't worth it.
Co-authored-by: Tyler Yahn <[email protected]>
da22953 to
1f2e8e0
Compare
1f2e8e0 to
22944a9
Compare
Depends on #7441, #7443This improves the concurrent performance of the fixed size reservoir's Offer function by 4x (i.e. 75% reduction). This improves the performance of Measure() for fixed-size reservoirs by 60% overall.
Accomplish this by:
wandnexttogether.Offer benchmarks:
Measure benchmarks: