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(x/params): add lru caching #3120

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

moul
Copy link
Member

@moul moul commented Nov 14, 2024

LRU caching uses a specified CacheMaxSize to limit the number of entries. Keys are immediately invalidated when a setter is called. The LRU is shared across all the getters.

Fix #3023
Related with #2911

@moul moul self-assigned this Nov 14, 2024
@github-actions github-actions bot added the 📦 🌐 tendermint v2 Issues or PRs tm2 related label Nov 14, 2024
Signed-off-by: moul <[email protected]>
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 85.18519% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.75%. Comparing base (a1812af) to head (a73eead).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
tm2/pkg/sdk/params/keeper.go 75.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3120      +/-   ##
==========================================
- Coverage   63.79%   63.75%   -0.04%     
==========================================
  Files         549      549              
  Lines       78819    79468     +649     
==========================================
+ Hits        50279    50664     +385     
- Misses      25150    25388     +238     
- Partials     3390     3416      +26     
Flag Coverage Δ
contribs/gnodev 61.16% <ø> (ø)
contribs/gnofaucet 14.82% <ø> (ø)
gno.land 73.71% <100.00%> (+0.01%) ⬆️
gnovm 67.94% <ø> (+<0.01%) ⬆️
misc/genstd 79.72% <ø> (ø)
tm2 62.41% <77.77%> (+0.07%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Nov 15, 2024
@moul moul marked this pull request as ready for review November 15, 2024 22:57
Signed-off-by: moul <[email protected]>
Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

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

What are the performance gains of this PR? K/V storages usually have cache mechanisms like the one implemented here, so maybe it is redundant?

EventSwitch events.EventSwitch // required
VMOutput io.Writer // optional
InitChainerConfig // options related to InitChainer
ParamsMaxCacheSize int // optional
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the int representing? Kb? Mb? The number of items?

@@ -7,6 +7,7 @@ import (
"github.com/gnolang/gno/tm2/pkg/amino"
"github.com/gnolang/gno/tm2/pkg/sdk"
"github.com/gnolang/gno/tm2/pkg/store"
"github.com/golang/groupcache/lru"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this lib is more maintained than the one used: https://github.com/hashicorp/golang-lru

Comment on lines +123 to +125
if bz == nil {
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the meaning of that code? can we have nil values in our cache? why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related
Projects
Status: 📥 Inbox
Status: In Review
Development

Successfully merging this pull request may close these issues.

sdk/params: add lazy caching with LRU
2 participants