CClaimTrieCache is caching Nodes inefficiently during updates #90
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
Epic
good first issue
hacktoberfest
hard fork
help wanted
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
soft fork
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
work in progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbrycrd#90
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
lbrycrd uses space inefficient map and set structure to cache Nodes (cacheing nodes is done when updating the claim trie structure to keep track of which node should or should not be updated)
CClaimTrieCache.cacheHashes -> (hashMapType, std::map<std::string, uint256> , stores hashes for each nodes
CClaimTrieCache.cache -> (nodeCacheType, std::map<std::string, CClaimTrieNode*>
CClaimTrieCache.block_originals -> (nodeCacheType)
CClaimTrieCache.dirtyHashes -> (std::setstd::string)
CClaimTrie.dirtyNodes -> (nodeCacheType)
This is problematic for caching large name claims (max length 255) since each subnode gets put into the map/set (i.e, claim "test" must cache "t", "te" ,"tes" , "test") thus 32 kilobytes alone (255*256 /2) is used to store the string keys for a max length name claim in the cache. We could improve the memory usage by utilizing a trie structure.
We actually do not have a base template trie class although ClaimTrie itself is a trie structure. It would make sense to create this base template tire class so that a) ClaimTrie can inherit from it and b) we can use it instead of map and set structure used to cache nodes.
Having a base trie class will also have the benefit of improving code readability and testability.
closing as this is a duplicate of https://github.com/lbryio/lbrycrd/issues/108 and https://github.com/lbryio/lbrycrd/issues/106