-
Notifications
You must be signed in to change notification settings - Fork 389
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
improvement: Use LRU instead of maps on defaultStore #780
Conversation
Can you explain why maps are exhausting plz ? EDIT: forget that, I didn't notice it was for caching. |
@ajnavarro, thank you, can you provide some metrics, i.e., benchmark before/after? Warn: new dependency, to be reviewed. cc @peter7891 good example of candidate for the performance management framework. |
"github.com/gnolang/gno/tm2/pkg/amino" | ||
"github.com/gnolang/gno/tm2/pkg/std" | ||
"github.com/gnolang/gno/tm2/pkg/store" | ||
) | ||
|
||
const iavlCacheSize = 1024 * 1024 // TODO increase and parameterize. | ||
const objectCacheSize = 100 // TODO parameterize. | ||
const typeCacheSize = 1000 // TODO parameterize. | ||
const nodeCacheSize = 10000 // TODO parameterize. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you evaluate those values ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Executing a stress test using supernova. Ideally, we should define a total max memory available for store cache.
Changing actual cache implementation to use an LRU cache improves resource usage and avoids exhaustion. Signed-off-by: Antonio Navarro Perez <antnavper@gmail.com>
d56846a
to
7c9a8df
Compare
I can create some benchmarks measuring the total memory used. |
@moul @tbruyelle I think I found a bug. After limiting the number of objects allowed to be on memory, some tests started to fail saying that a package is missing from the store (it should be there if it was on the cache before). That might be considered a bug. WDYT? |
Sure, what is the error exactly ? |
I found the problem. The store interface has a IMHO a better solution would be to store these temporal packages on a persistent storage that can be deleted eventually. |
OK so to be sure I understand well, some packages (I assume the ones added via |
Hmm, The problem with the actual change is that
|
OK that's what I understood, the packages that are manually put in cache via |
I asked @zivkovicmilos to make this PR a draft because I'll need more time to think about throwaway packages. |
Closing in favor of #812 to try to define the best solution. |
Description
Changing actual cache implementation to use an LRU cache improves resource usage and avoids exhaustion.