awesome-everything RU
↑ Back to the climb

Performance

Cache vs big-O: free-recall review

Crux Free-recall prompts across the cache-vs-big-O unit. Answer each from memory first, then reveal the model answer and compare.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 14 min

Retrieval beats re-reading. For each prompt, say or write a full answer from memory before you open the model answer — the effort of recall is what fixes the mental model, not the recognition of a right-looking option.

Goal

Reconstruct the unit’s spine without looking back: why allocation pattern beats operation count, how the cache line creates false sharing, when sorting beats branchless code, why SoA enables SIMD, and the perf-stat loop that ties it together.

Recall before you leave
  1. 01
    Why can an O(N) scan of a contiguous array beat an O(log N) tree traversal in production, and where does that stop being true?
  2. 02
    Explain false sharing: how the MESI protocol turns independent per-thread writes into a performance bug, and how you detect and fix it.
  3. 03
    When does sorting (O(N log N)) beat a branchless rewrite for a data-dependent branch, and when is branchless the better tool?
  4. 04
    Why does SoA enable SIMD where AoS forces gather/scatter, and what is the trade-off?
  5. 05
    Beyond cache hit rate, what two constraints limit a memory-bound loop, and how do you tell them apart from cache misses?
  6. 06
    State the performance-engineering loop for this unit and which metric points to which class of fix.
Recap

If you reconstructed each answer from memory, you hold the unit’s spine: the memory hierarchy sets a ~100x constant that big-O ignores; cache lines are 64-byte ownership units that turn neighbouring writes into false sharing; sorting and branchless are two tools for the same unpredictable-branch problem; SoA unlocks SIMD and bandwidth that AoS blocks; and the perf-stat loop maps each metric to its matching fix. Measure first, name the constant-factor cause, fix layout or branches, re-measure.

Continue the climb ↑Cache vs big-O: code and layout reading
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.