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
Kan/clean up secondary result index #1515
Conversation
Kay-Zee
commented
Oct 22, 2021
- Fix the secondary index memory leak
- Add test for confirming secondary index also stays at "limit"
- Fix Incorporated results tests that weren't working as intended
func TestApprovalsLRUCacheSecondaryIndexPurge(t *testing.T) { | ||
numElements := uint(10) | ||
cache := NewApprovalsLRUCache(numElements) | ||
approvals := make([]*flow.ResultApproval, 2*numElements) |
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.
It seems this approvals
field isn't really necessary? We don't actually do anything with the approvals we store inside.
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.
Maybe you actually meant to add a check?
for i := range results { | ||
result := unittest.IncorporatedResult.Fixture() | ||
results[i] = result | ||
require.True(t, cache.Put(result.ID(), result)) | ||
require.Equal(t, result, cache.Get(result.ID())) | ||
} | ||
require.ElementsMatch(t, results, cache.All()) | ||
require.Equal(t, int(numElements), len(cache.All())) |
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.
same comments here as above.
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.
LGTM. Thanks
Codecov Report
@@ Coverage Diff @@
## master #1515 +/- ##
==========================================
+ Coverage 55.09% 55.15% +0.05%
==========================================
Files 521 521
Lines 32514 32515 +1
==========================================
+ Hits 17914 17933 +19
+ Misses 12192 12173 -19
- Partials 2408 2409 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Co-authored-by: Simon Zhu <simon.zsiyan@gmail.com>
* Remove from secondary index * Add tests for caches * add concurrency test * Apply suggestions from code review Co-authored-by: Simon Zhu <simon.zsiyan@gmail.com> Co-authored-by: Leo Zhang (zhangchiqing) <zhangchiqing@gmail.com> Co-authored-by: Simon Zhu <simon.zsiyan@gmail.com>
* fix potential mem-leak from hotstuff (#1514) * Kan/clean up secondary result index (#1515) * Remove from secondary index * Add tests for caches * add concurrency test * Apply suggestions from code review Co-authored-by: Simon Zhu <simon.zsiyan@gmail.com> Co-authored-by: Leo Zhang (zhangchiqing) <zhangchiqing@gmail.com> Co-authored-by: Simon Zhu <simon.zsiyan@gmail.com> * disable cache metrics Co-authored-by: Kan Zhang <kan@axiomzen.co> Co-authored-by: Simon Zhu <simon.zsiyan@gmail.com>