x86, what resources of the memory subsystem (core and uncore) can get congested by a busy reader?

2026-06-19

Stack Overflow: View Question

Tags: x86, cpu-architecture

Score: 3 | Views: 102

The asker is building a single-producer/single-consumer (SPSC) queue and wants to understand which shared microarchitectural resources a "busy reader" — a consumer that spins reloading a cache line — can saturate. The concern is subtle false sharing: even when producer and consumer touch logically distinct lines, they may contend on hidden structures the PMU doesn't expose cleanly.

Why it's hard: The memory subsystem on modern x86 is a stack of queues, buffers and trackers, many of which Intel/AMD only partially document. A spinning reader doesn't just "read memory" — it pushes traffic through:

A "busy reader" hitting the same line repeatedly mostly stays in L1 once warm, costing nothing. But the moment the producer writes — invalidating the line — the reader's next load takes a long round trip through the CHA to fetch the modified copy from the producer's core. That coherence handshake is the real cost, and the consumer's pending miss occupies an LFB the entire time.

Direction toward an answer:

Gotchas: a single spinner on one line looks cheap because the LFB coalesces. Multiple readers, or a reader that touches neighboring lines (adjacent-line prefetcher pulls them in), can quietly cause snoops to lines the producer thought it owned exclusively. Padding to two cache lines (128B) — not one — is the conservative answer on Intel because of that prefetcher.

The challenge: The interesting resources to monitor (LFBs, super-queue, CHA tor occupancy) live in poorly-documented uncore PMU events that change every CPU generation, so even framing the measurement correctly is half the problem.

All newsletters