Skip to content
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

Merged
merged 7 commits into from Oct 22, 2021

Conversation

Kay-Zee
Copy link
Member

@Kay-Zee 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)
Copy link
Contributor

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.

Copy link
Contributor

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?

engine/consensus/approvals/caches_test.go Outdated Show resolved Hide resolved
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()))
Copy link
Contributor

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.

Copy link
Member

@durkmurder durkmurder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks

@codecov-commenter
Copy link

codecov-commenter commented Oct 22, 2021

Codecov Report

Merging #1515 (2545d95) into master (054feed) will increase coverage by 0.05%.
The diff coverage is 100.00%.

❗ Current head 2545d95 differs from pull request most recent head c4e4e88. Consider uploading reports for the commit c4e4e88 to get more accurate results
Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 55.15% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
engine/consensus/approvals/approvals_lru_cache.go 53.65% <100.00%> (+53.65%) ⬆️
...ngine/common/synchronization/finalized_snapshot.go 68.75% <0.00%> (-4.17%) ⬇️
module/component/component.go 37.86% <0.00%> (-0.98%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72fd04c...c4e4e88. Read the comment docs.

@zhangchiqing zhangchiqing merged commit aa41a3b into master Oct 22, 2021
@zhangchiqing zhangchiqing deleted the kan/clean-up-secondary-result-index branch October 22, 2021 18:29
zhangchiqing added a commit that referenced this pull request Oct 22, 2021
* 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>
zhangchiqing added a commit that referenced this pull request Oct 22, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants