solana/runtime
behzad nouri a49ef49f87
optimizes ReadOnlyAccountsCache LRU eviction implementation (#22403)
ReadOnlyAccountsCache is using a background thread, table scan and sort
to implement LRU eviction policy:
https://github.com/solana-labs/solana/blob/eaa52bc93/runtime/src/read_only_accounts_cache.rs#L66-L73
https://github.com/solana-labs/solana/blob/eaa52bc93/runtime/src/read_only_accounts_cache.rs#L186-L191
https://github.com/solana-labs/solana/blob/eaa52bc93/runtime/src/read_only_accounts_cache.rs#L222

DashMap internally locks each shard when accessed; so a table scan in
the background thread can create a lot of lock contention.

This commit adds an index-list queue containing cached keys in the order
that they are accessed. Each hash-map entry also includes its index into
this queue.
When an item is first entered into the cache, it is added to the end of
the queue. Also each time an entry is looked up from the cache it is
moved to the end of queue. As a result, items in the queue are always
sorted in the order that they have last been accessed. When doing LRU
eviction, cache entries are evicted from the front of the queue.
Using index-list, all queue operations above are O(1) with low overhead
and so above achieves an efficient implementation of LRU cache eviction
policy.
2022-01-11 17:25:28 +00:00
..
benches move AccountInfo to its own file (#21784) 2021-12-11 11:47:05 -06:00
src optimizes ReadOnlyAccountsCache LRU eviction implementation (#22403) 2022-01-11 17:25:28 +00:00
store-tool Bump version to v1.10.0 2021-12-04 20:17:54 +00:00
tests Reformat imports to a consistent style for imports 2021-12-03 09:19:13 -08:00
.gitignore
Cargo.toml optimizes ReadOnlyAccountsCache LRU eviction implementation (#22403) 2022-01-11 17:25:28 +00:00
build.rs Remove frozen ABI modules from solana-sdk 2020-10-20 16:11:30 -07:00