Audit hot paths for performance inefficiencies (allocations, contention, layout)
Audit the Caffeine cache for performance inefficiencies.
Context: Caffeine runs in high-throughput, low-latency JVM services where cache operations occur millions of times per second. The library is already heavily optimized — generic textbook advice is not useful.
Trace get()/getIfPresent() from entry to return. Count volatile/opaque reads, method calls, branches, allocations. Even one saved volatile read matters.
Identify allocations surviving escape analysis on hot paths. Frequency, size, lifetime. Do not flag JIT-eliminated allocations.
CAS retry rates, cache-line bouncing, graceful vs catastrophic degradation for read buffer, evictionLock, CHM bins, node field updates.
Counter layout locality, hash computation, reset cost. Accessed every read/write.
Worst-case work per write, latency spikes, eviction cascades, timer wheel scan cost.
Node object size, pointer indirection depth, false sharing, @Contended opportunities.
For each finding:
## [Category] Title
**Location:** file:method (lines X-Y)
**Severity:** negligible | moderate | high
**What happens:** (trace the code path)
**Why it matters:** (quantify)
**JIT considerations:** (will C2 handle this?)
**Proposed fix:** (specific code change)
**Expected benchmark impact:** (JMH prediction)
If fewer than 3 real issues, the code is well-optimized. Do not pad the output.