summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-04-08 17:13:18 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-09 12:12:51 -0600
commit86f83b75c73d9eb2e1f8733a02ce12c58f563530 (patch)
tree0cdd48819904897cc2f65214a4b57d881c86082d
parent68eb7a16b9759646619a7d9dec2b62fa9d0c30cf (diff)
containers: ARCache: Don't count "nested" uses as "frequent" uses
This is a modification to how "pinning" is implemented, that should hopefully result in better performance of the ARC policy.
-rw-r--r--lib/containers/arcache.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/containers/arcache.go b/lib/containers/arcache.go
index 29ec030..deb80f0 100644
--- a/lib/containers/arcache.go
+++ b/lib/containers/arcache.go
@@ -504,9 +504,12 @@ func (c *arCache[K, V]) Acquire(ctx context.Context, k K) *V {
switch {
case c.liveByName[k] != nil: // cache-hit
entry = c.liveByName[k]
- if entry.List != &c.frequentPinned {
- // Move to frequentPinned (unless it's already
- // there; in which case, don't bother).
+ // Move to frequentPinned, unless:
+ //
+ // - it's already there; in which case, don't bother
+ // - it's in recentPinned; don't count "nested" uses
+ // as "frequent" uses.
+ if entry.List != &c.frequentPinned && entry.List != &c.recentPinned {
entry.List.Delete(entry)
c.frequentPinned.Store(entry)
}