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

chore(lib/trie): use map for trie.getInsertedNodeHashes to reduce memory pressure #2115

Merged
merged 5 commits into from
Jan 10, 2022

Conversation

qdm12
Copy link
Contributor

@qdm12 qdm12 commented Dec 13, 2021

Changes

  • Use a map to store the set of hashes of inserted nodes for getInsertedNodeHashes
  • Refactor calling code of getinsertedNodeHashes to use a map (set) in order to:
    • avoid confusion about the order of hashes
    • improve performance and avoid copying the map back to a slice
  • Extend map-set concept to deletedKeys in order to simplify calling code

Tests


Issues

Primary Reviewer

@codecov
Copy link

codecov bot commented Dec 13, 2021

Codecov Report

Merging #2115 (8a64b5b) into development (8fd1511) will increase coverage by 0.01%.
The diff coverage is 19.35%.

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

@@               Coverage Diff               @@
##           development    #2115      +/-   ##
===============================================
+ Coverage        61.49%   61.50%   +0.01%     
===============================================
  Files              213      213              
  Lines            27429    27437       +8     
===============================================
+ Hits             16867    16875       +8     
+ Misses            8692     8691       -1     
- Partials          1870     1871       +1     
Flag Coverage Δ
unit-tests 61.50% <19.35%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
lib/runtime/storage/trie.go 53.89% <0.00%> (ø)
lib/trie/database.go 50.33% <0.00%> (-1.39%) ⬇️
lib/trie/trie.go 91.62% <75.00%> (ø)
dot/state/storage.go 49.75% <100.00%> (ø)
dot/network/test_helpers.go 79.02% <0.00%> (-3.50%) ⬇️
dot/network/message.go 66.52% <0.00%> (-2.61%) ⬇️
lib/runtime/wasmer/imports.go 48.71% <0.00%> (+0.05%) ⬆️
lib/blocktree/blocktree.go 54.90% <0.00%> (+1.09%) ⬆️
lib/grandpa/vote_message.go 81.96% <0.00%> (+1.22%) ⬆️
lib/grandpa/message.go 63.30% <0.00%> (+2.15%) ⬆️
... and 1 more

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 c471064...cb0d6d9. Read the comment docs.

Copy link
Member

@EclesioMeloJunior EclesioMeloJunior left a comment

Choose a reason for hiding this comment

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

looks good! nice replacement!

dot/state/pruner/pruner.go Show resolved Hide resolved
Base automatically changed from qdm12-trie-database-1 to development January 5, 2022 15:13
@qdm12 qdm12 force-pushed the qdm12-trie-getinsertednodehashes branch from 3eac291 to 8a64b5b Compare January 5, 2022 16:18
lib/trie/database.go Outdated Show resolved Hide resolved
Copy link
Contributor

@noot noot left a comment

Choose a reason for hiding this comment

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

looks good! btw, this pruning code isn't run by default, by default the node is archive

- Avoid confusion about slice order of hashes
- Faster to return a map than transforming it to a slice
- Uniformize together with inserted keys
- Refactor calling code
@qdm12 qdm12 force-pushed the qdm12-trie-getinsertednodehashes branch from 8a64b5b to 08c9d92 Compare January 6, 2022 11:11
@danforbes
Copy link
Contributor

Does this relate to #1973?

@qdm12
Copy link
Contributor Author

qdm12 commented Jan 7, 2022

Does this relate to #1973?

This was done as a PR to the branch of #2108 (faster to do it than to create an issue imo).

It's more about #1494

@qdm12 qdm12 merged commit 6aee618 into development Jan 10, 2022
@qdm12 qdm12 deleted the qdm12-trie-getinsertednodehashes branch January 10, 2022 20:38
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.

4 participants