About this question
Hard · memory_optimization · Quant Developer interview question · type-erasure, sbo, small-buffer-optimization, memory_optimization, template, callable
High-frequency trading (HFT) systems often register thousands of callbacks for market data updates, where the performance cost of std::function's heap allocations becomes prohibitive. To eliminate this overhead, a custom type-erased callable with Small Buffer Optimization (SBO) is used, storing small function objects (like stateless lambdas) inline to avoid dynamic memory allocation. This pattern is crucial for building low-latency systems that handle vast numbers of instruments efficiently. Ta