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

feat(trie): Implement LRU cache for in memory trie #3624

Closed
wants to merge 7 commits into from

Conversation

dimartiro
Copy link
Contributor

Changes

We added an implementation for a LRU cache to be used in our in memories tries and prevent having the entire trie list in memory with the goal of reducing the memory usage

Tests

make test

Issues

#3623

Primary Reviewer

@timwu20

c.Lock()
defer c.Unlock()

return len(c.cache)
Copy link
Member

Choose a reason for hiding this comment

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

lruList has Len() attribute, it is 100% O(1) complexity while I am not sure about bult-in function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -30,11 +29,12 @@ var (
})
)

const MaxInMemoryTries = 100
Copy link
Member

@P1sar P1sar Dec 5, 2023

Choose a reason for hiding this comment

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

How this was defined? Should we maybe add some description for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is still WIP, I want to use the same number used in substrate but I have to do a little research to find it. We don't use to review draft PRs because the code can change. Anyways, thanks for the comment.

Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Merging #3624 (116afa8) into development (7ebf37a) will increase coverage by 0.29%.
Report is 5 commits behind head on development.
The diff coverage is 89.13%.

❗ Current head 116afa8 differs from pull request most recent head a7cff46. Consider uploading reports for the commit a7cff46 to get more accurate results

Additional details and impacted files
@@               Coverage Diff               @@
##           development    #3624      +/-   ##
===============================================
+ Coverage        50.16%   50.46%   +0.29%     
===============================================
  Files              229      229              
  Lines            28585    28608      +23     
===============================================
+ Hits             14340    14437      +97     
+ Misses           12723    12648      -75     
- Partials          1522     1523       +1     

@dimartiro
Copy link
Contributor Author

Closing it. We are implementing the same in #3658

@dimartiro dimartiro closed this Jan 16, 2024
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.

2 participants