Low-Latency Trading Systems in C++: Templated Meta-State Machines in HFT
summary
Generates a computed goto from heavy template meta-programming: a templated meta-state-machine using an unordered_tuple of placement-new transitions and a constrained_override_type to recover type-safe virtual-like dispatch. Builds a custom perfect-hash by brute force with a data-parallel finder (single-thread brute force ~15 min, parallel ~2 min) and emits header-instantiated hash templates. Result: computed-goto is achievable but compile- and build-costs explode, performance gains versus naive if-else are marginal and compiler-dependent, hitting the noise floor.
AI-written summary · about
chapters (11)
- 0:00Low-latency trading systems intro
- 1:25Templated meta-state machines in HFT
- 10:57Premature optimization pitfalls
- 27:37Constrained override type design
- 45:32Unordered tuple for state transitions
- 51:44Minimal perfect hash functions
- 1:00:19Micro-benchmarking meta-state machine
- 1:06:03Full-system performance results
- 1:14:54Complexity vs maintainability
- 1:20:51Conclusions and lessons
- 1:24:30Epilogue
related talks
01h 08mTemplate Meta-State Machines, Madness and Shannon
05mLightning Talk: Powered by C++20 Meta-Programming (MP)
01h 00m“State Machines Battlefield - Naive vs STL vs Boost”
01h 13mModernizing Finite State Machines in C++ - Empower Simplicity & Boost Performance With std::variant
01h 00mModern Template Metaprogramming: A Compendium, Part I
05m[BOOST].SML STATE MACHINE LANGUAGE
01h 30mRethinking the Way We Do Templates in C++
01h 06m“C++ Metaprogramming: Journey from simple to insanity and back"
