Cache Misses: Default Allocators' Hidden Performance Drain

Default allocators often fail to guarantee memory locality or optimal cache-line alignment, leading to frequent CPU cache misses that force the CPU to fetch data from slower memory levels, severely degrading HFT application speed.

The top 3

  1. Cache Miss Penalties: Cycles Lost per Level: Accessing data from main memory after an L3 cache miss can cost hundreds of CPU cycles (e.g., 100-300 cycles), significantly more than an L1 miss (around 1-4 cycles) or an L2 miss (7-14 cycles), highlighting the exponential performance degradation across the memory hierarchy.
  2. Data vs. Instruction: Which Cache Misses Hurt Most?: While both data and instruction cache misses impact performance, data cache misses are often more critical for data-intensive applications like HFT due to unpredictable memory access patterns exacerbated by default allocators.
  3. Cache Line Inefficiency: Default Allocators' Wasted Space: Default memory allocators can cause cache misses by failing to align data optimally and leading to fragmented memory, which results in poor spatial locality. This means that when a CPU fetches a 64-byte cache line, much of the data brought into the cache may not be immediately useful, wasting valuable cache space and bandwidth.

Sources

Open the full topic