Default Allocators' Microsecond Latency Impact on HFT
Standard memory allocators like `malloc` can introduce latency spikes ranging from tens to hundreds of nanoseconds, occasionally even milliseconds, which is catastrophic in high-frequency trading where a single microsecond can translate to millions in annual profits.
The top 3
- Default Allocators: Up to 10 Microseconds Latency Cost: Standard memory allocators like `malloc` or `new` can introduce significant and unpredictable delays, with a single dynamic allocation potentially costing up to 10 microseconds in high-frequency trading (HFT) systems. This cost drives firms to pre-allocate massive memory pools (e.g., 64GB) to avoid runtime allocations.
- Jitter: HFT's Unpredictable Latency Nemesis: Beyond raw speed, the unpredictable nature, or 'jitter,' introduced by default memory allocators is a critical problem in HFT. Deterministic and consistent latency is more valued than occasional brilliance, as unpredictable delays can damage strategy quality and trust in the system.
- HFT's Golden Rule: Never Allocate on the Hot Path: A fundamental principle in HFT is to avoid dynamic memory allocation on the 'hot path'—the most latency-critical sections of code. This leads to widespread use of techniques like pre-allocation, where all necessary memory is reserved upfront before trading begins, creating a ready-to-use pool of objects to eliminate runtime memory requests.
Sources
Open the full topic