-
Notifications
You must be signed in to change notification settings - Fork 619
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
Consider adding LRU cache to RocksDB impl of Database #5203
Comments
Rocksdb has in-memory cache internally and we have it enabled. |
Given the complexity of Rocksdb and that we revisited its configuration only once, I don't think we can be sure that we configured it correctly or that it is optimized for the view calls. |
Indeed, we currently set the cache size for all columns to be 32mb Line 664 in 6d8eee6
ColState . For example, we can do 256mb or even 512 for ColState . @mina86 @pmnoxx given that you worked with Rocksdb before, I wonder whether this is something you could help with.
|
@bowenwang1996 I can write a PR like this: #5212 |
We recently found out that our rockdb is not efficient enough. Therefore we would like to increase cache size of specific columns. In this PR we will increase cache size for `DBCol::ColState` to 128mb. We can adjust that cache size later, but we try to be conservative in memory usage. Some testing should be done to determine optimize cache sizes. Closes #5203
I would suggest to make this parameter a node configuration. This way RPC nodes can configure a larger cache if they have more RAM compared to validator nodes or other nodes that don't need to constantly respond to view calls |
@ilblackdragon I can add it to |
This issue has been automatically marked as stale because it has not had recent activity in the last 2 months. |
State column cache size param is already implemented #6584 |
We haven't had an opportunity to optimize the performance of the RPC server and the ViewClient inside nearcore. Which leads to individual RPC nodes not being able to sustain the needed throughput, which in turn leads to high cloud expenses for running multiple nodes and the need to use throttling.
Anecdotally, some people were able to optimize RPC server to achieve higher QPS by using Redis in nearcore: https://twitter.com/vgrichina/status/1458289037525934084 . We might be able to achieve QPS increase by simpler means as a temporary measure until we revisit RPC server and ViewClient implementations. I suggest we consider adding simple LRU cache from https://docs.rs/cached/0.26.2/cached/ directly into
get
andwrite
methods ofimpl Database for RocksDB
here:nearcore/core/store/src/db.rs
Lines 469 to 563 in 7349786
write
method would be responsible for invalidating LRU cache entries.Unfortunately, AFAIR there is a suboptimality in
near-api-js
that forces it re-request all access from an account before signing a transaction. This will likely touchiter_*
methods (likelyiter_prefix
method) ofimpl Database for RocksDB
, which we might also want to wrap in cache. CC @MaximusHaximus , @frolWe most likely would want to have this cache enabled only for the RPC nodes, and we should let the Contract Runtime team know about its existence, since it might affect the measurements of the param estimator.
The text was updated successfully, but these errors were encountered: