Uses dashmap for cache_for_accounts_lt_hash #4148
Open
+28
−44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The accounts lt hash cache is a HashMap behind a single RwLock. When inserting into the cache, we do a lookup with a read lock, then—if not present—do an insert with a write lock. This can have contention with other replay threads also trying to access/update the cache.
Summary of Changes
Replace the cache's RwLock + HashMap with a DashMap.
Results
I ran this PR vs master (ish), both with the accounts lt hash cli arg enabled. Since upsert into the cache is part of tx processing, we want to reduce latency as much as possible. The upsert is two parts: first, lookup to see if present (read lock only), and second, if not present, insert (with write lock).
brux1 is this PR, brux2 is master.
for lookup, brux1 is red and brux2 is yellow
lookup mean: dashmap is faster on average
lookup max: dashamp has better worst-case lookup times
The speedup in lookup (above) is the main win. The time spent inserting is mostly the same.
Here's a graph of the sum of the total inspect time (lookup + insert), which also shows a speed up with this PR.
brux1 is blue, brux2 is purple.