Interview practice question
Per-thread counters scale badly
Backend Engineering · Language Runtimes · Experienced
Your service keeps per-thread statistics counters in an array, and performance gets worse as you add threads, even though threads never touch each other's counters. Why?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- False sharing on same cache line.
- Cores invalidate each other's caches.
- Pad counters to separate cache lines.
- Java @Contended, LongAdder.
- Aggregate locally, publish periodically.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.