a49ef49f87
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. |
||
---|---|---|
.. | ||
address-lookup-table | ||
address-lookup-table-tests | ||
bpf | ||
bpf_loader | ||
compute-budget | ||
config | ||
stake | ||
vote | ||
zk-token-proof |