Skip to content

Commit

Permalink
Fix BTree cache CPU trashing eviction
Browse files Browse the repository at this point in the history
Cache refuses to evict inner nodes, and scans the entire cache looking for non-inner nodes, which become increasingly rare.

Ditch the inner node policy, instead just ensure LRU is updated on get(). Why was it not already doing so ? That is the point of an LRU.

I was seeing queries where > 70% of the CPU was spend on BTreeCache.removeNext(). That’s completely fixed; such queries are now 5x faster.
  • Loading branch information
alanpaxton authored and adamretter committed Dec 1, 2024
1 parent 698d3e4 commit cd3bc3a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public SequencedLongHashMap(final int iSize) {
* @return the value associated with the key, or null if the key is absent
*/
public @Nullable V get(final long key) {
return map.get(key);
return map.getAndMoveToLast(key);
}

/**
Expand Down

0 comments on commit cd3bc3a

Please sign in to comment.