Skip to content

PR 0047 lru skip free node scans when the cache is

github-actions[bot] edited this page Sep 14, 2026 · 1 revision

PR #47 — lru: skip free-node scans when the cache is full

PR #47

Status

  • GitHub state: Merged
  • Disposition at review: Merged
  • Current head at review: ff9625dddb32e9c5e60f548c5c19015f4d0a6f54 (fix/lru-full-cache-scan)
  • Reviewed head: ff9625dddb32e9c5e60f548c5c19015f4d0a6f54
  • Last reviewed: 2026-09-14 UTC
  • Base: release/eng-2026-523-stable-v2-final at d9bf8e1dcfd4ee72813c9f9f5572b780fc65cc76
  • Subsystem: Core utility / cache

Review freshness: this page records the final/known PR head at review time. If the PR is reopened or rewritten, re-review before relying on implementation details.

At a glance

  • What it changes: lru: skip free-node scans when the cache is full
  • Why it was attempted: Observed problem: A miss in a full LRU cache traversed the complete global list searching for free storage even though the maintained num free count already proved there were no free nodes. Profiling evidence: The production-header regression records exact loop visits. At 4,096 entries and 1,024 saturated misses, the parent performs 4,194,304 unsuccessful free-node visits before the normal 1,024 eviction visits. Suspected cause: lru get one free() always…
  • Current/final result: Merged isolated LRU fast-path repair with focused unit coverage.
  • Lesson: When LRU bookkeeping already proves the cache is full, skip scanning for a free node; encode that invariant with focused full-cache tests.

Code impact

Implementation file Δ Why it matters
include/qemu/lru.h +4/-0 Generic LRU cache lookup/eviction fast path.
tests/unit/meson.build +1/-0 Focused/regression validation for the implementation contract.
tests/unit/test-lru-full.c +238/-0 Focused/regression validation for the implementation contract.

Flow

flowchart LR
    subgraph Before
        A[Core utility / cache input] --> B[Existing path] --> C[Observed limitation/cost] --> D[Guest-visible result]
    end
    subgraph PR_47[PR #47]
        E[Core utility / cache input] --> F[PR #47 change/measurement] --> G[Qualified behavior] --> H[Guest-visible result]
    end
Loading

What changed

Skip lru get one free() free-node traversal when num free == 0 . - Preserve the existing eviction operation and callback/veto contracts. - Add production-header regression coverage for full/partial caches, hits, collisions, vetoes, flush/reuse, and exhaustion. Main code path: include/qemu/lru.h , tests/unit/test-lru-full.c Commits: tested f75368d4d358b5e87765fe953df49f646533914f ; merged as bac2cae991a2d359eddfc6836dec3db60fba5618

Result

Merged isolated LRU fast-path repair with focused unit coverage.

Lesson learned

When LRU bookkeeping already proves the cache is full, skip scanning for a free node; encode that invariant with focused full-cache tests.

Avoid repeating

Do not add LRU shortcuts without tests covering empty, partially occupied, full, and eviction states.

Docs / evidence

Pointers only; the detailed evidence remains in its original location.

  • docs/performance/lru-full-cache/

Related architecture

Clone this wiki locally