Skip to content

feat: eliminate false sharing via cache-line alignment (#4) - #11

Merged
HawkinWay merged 2 commits into
mainfrom
4-feature-cache-aligned-indices
Jul 25, 2026
Merged

feat: eliminate false sharing via cache-line alignment (#4)#11
HawkinWay merged 2 commits into
mainfrom
4-feature-cache-aligned-indices

Conversation

@HawkinWay

Copy link
Copy Markdown
Owner

The Problem: False Sharing

Previously, write_idx and read_idx resided on the same 64-byte cache line. When the producer thread updated write_idx, the CPU hardware MESI protocol invalidated the entire cache line on the consumer core, creating severe Cache Line Bouncing and stalling execution despite using fine-grained Acquire-Release semantics.

Solution

  • Applied alignas(hardware_destructive_interference_size) (or 64-byte fallback) to separate write_idx and read_idx onto distinct cache lines.
  • Suppressed GCC -Winterference-size ABI warnings by providing explicit cache-line constants/flags where applicable.

@HawkinWay
HawkinWay merged commit 49ba4be into main Jul 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant