The latency gap between L2 and L3 cache has a direct and very visible impact on how database buffer caches behave—especially on large SMP systems like IBM POWER10.
At a high level:
-
L2 hit → very fast (low tens of cycles)
-
L3 hit → significantly slower (often ~2–3× L2 latency)
That difference shapes how efficiently the database buffer cache serves data.
🔷 1. What “Buffer Cache Access” Looks Like
Database buffer cache (Oracle/DB2/Postgres) stores:
-
Frequently accessed data pages (8KB, 16KB, etc.)
-
Index blocks
-
Metadata
Typical access path:
👉 Performance depends heavily on how often data stays in L2 vs spills to L3.
🔷 2. Impact of L2 Latency (Fast Path)
When buffer cache data hits in L2:
🚀 Very low latency access
-
Fast pointer chasing (index lookups)
-
Quick latch/mutex operations
🚀 High OLTP efficiency
-
OLTP queries repeatedly access same hot blocks
-
These blocks tend to stay in L2
👉 Result:
-
Low response time
-
High transactions per second (TPS)
🔷 3. Impact of L3 Latency (Shared, Slower)
When data misses L2 and hits L3:
🔸 Increased access latency
-
Each access takes significantly longer
-
Affects tight loops (index traversal, joins)
🔸 Contention effects
-
L3 is shared across cores/threads
-
Multiple workloads compete
👉 Leads to:
-
Variable latency
-
Tail latency spikes
🔸 Reduced OLTP predictability
-
Even small delays compound:
-
Lock acquisition
-
Row access
-
Commit paths
👉 OLTP becomes less consistent
🔷 4. Buffer Cache Access Patterns
🔹 OLTP (Index-driven)
Pattern:
-
Repeated access to small set of blocks
-
Pointer chasing (B-tree traversal)
✔ Best case:
❌ If pushed to L3:
-
Latency multiplies across steps:
👉 Query slows noticeably
🔹 OLAP (Scan-heavy)
Pattern:
-
Large sequential reads
-
Streaming access
Behavior:
-
Data rarely reused quickly
-
Mostly bypasses L2 effectiveness
👉 L3 (and memory) dominate performance
🔷 5. L2 vs L3 in Mixed Workloads
This is where it gets interesting.
❌ Problem: OLAP pushes OLTP out of L2
-
OLAP scans bring large volumes of data
-
L2 cache gets churned
-
OLTP hot blocks get evicted to L3
👉 Result:
-
OLTP latency increases
-
More L3 hits instead of L2
❌ Amplified by SMT (POWER10)
-
Multiple threads share L2/L3 resources
-
More contention → fewer L2 hits per thread
🔷 6. Latency Amplification Effect
Even a small latency increase matters because:
Example:
-
Index lookup = 3–4 pointer hops
If:
-
L2 hit = ~10 cycles
-
L3 hit = ~30 cycles
👉 Total:
-
L2 path ≈ 40 cycles
-
L3 path ≈ 120 cycles
➡️ 3× slowdown for same query
🔷 7. Why L2 Residency is Critical
Keeping buffer cache “hot” in L2 gives:
-
Faster latch acquisition
-
Faster row access
-
Better concurrency scaling
👉 This is why OLTP tuning focuses on:
-
Working set locality
-
Cache friendliness
🔷 8. How POWER10 Helps
✅ Large private L2 caches
-
Improves per-core locality
✅ High-bandwidth L3
-
Softens penalty when L2 misses
✅ Prefetch tuning
-
Avoids unnecessary L2 pollution
✅ SMT-aware scheduling
-
Balances cache usage across threads
🔷 9. Practical Database Implications
🔹 For OLTP tuning:
-
Keep hot data small → fits in L2
-
Avoid large scans during peak load
🔹 For OLAP:
-
Accept L3/memory latency
-
Optimize for throughput, not latency
🔹 For mixed workloads:
-
Isolate workloads if possible
-
Control scan aggressiveness
-
Use caching strategies (buffer pools, partitions)
✅ Bottom Line
The L2 vs L3 latency gap determines:
-
How fast buffer cache lookups are
-
How predictable OLTP performance remains
👉 L2 hits:
-
Enable low-latency, high-TPS transactions
👉 L3 hits:
-
Introduce higher latency and variability