Low-Latency C++ for Trading
A 16-week live course that teaches low-latency C++ by building and measuring a matching engine.
Curriculum
LAT-01Modern C++ for Performance3 lessons · 20 h
- Move semantics and value categories
- RAII, templates and constexpr
- Hidden allocations in standard library calls
LAT-02How the CPU Actually Runs Your Code3 lessons · 20 h
- Cache hierarchy and cache lines
- Prefetching and pipelines
- Branch prediction and the TLB
LAT-03Memory: Layout, Allocation & Pools3 lessons · 20 h
- Struct-of-arrays vs array-of-structs
- Alignment and object pools
- Arena allocators and flat containers
LAT-04Concurrency & the C++ Memory Model3 lessons · 25 h
- Atomics and memory ordering
- False sharing
- SPSC and MPSC ring buffers
LAT-05Compile-Time Techniques3 lessons · 15 h
- CRTP and templates
- constexpr instead of virtual dispatch
- Moving work out of the hot path
LAT-06Measurement & Profiling3 lessons · 15 h
- rdtsc timing and perf
- Google Benchmark
- Reading assembly and benchmarking pitfalls
LAT-07System Tuning & Networking3 lessons · 20 h
- Core pinning, isolated CPUs and huge pages
- NUMA and busy-polling
- UDP multicast and kernel-bypass overview
LAT-08Capstone: Order Book & Matching Engine3 lessons · 25 h
- Limit order book and matching engine
- Feed handler end to end
- Profiling, tuning and tail-latency write-up
What's included
Questions
Do I need prior experience?
This course is set at intermediate level. The first module starts from the basics, so you only need the time and a laptop or phone with a stable connection.
What if I miss a live class?
Every live class is recorded and posted within 24 hours. You keep access to the recordings for 12 months.
When are the classes?
The next cohort starts soon (date to be announced) and runs for 16 weeks, ~10 hrs per week. The full timetable and class link appear in My courses before the first class.
Which language is the course taught in?
English.
How do I pay?
Online through UPI, cards, net banking or wallets, processed by Razorpay. You get a receipt by email and the course appears in My courses right away.
Q01What is RAII?C++Basic
Resource Acquisition Is Initialisation: a resource such as memory, a file or a lock is acquired in a constructor and released in the destructor.
Because destructors run when scope ends, even during an exception, resources cannot leak. std::unique_ptr and std::lock_guard are standard examples.
Q02Why is std::vector usually faster than std::list?ContainersBasic
A vector stores elements contiguously, so the CPU prefetches them and cache hits are high.
A list allocates every node separately and walking it means chasing pointers, which causes cache misses. For most sizes a vector wins even for inserts in the middle.
Q03What are move semantics?C++Intermediate
Moving transfers resources from an object that is about to be discarded instead of copying them. std::move casts a value to an rvalue so the move constructor is chosen.
Mark move constructors noexcept, otherwise std::vector copies instead of moving when it reallocates.
Q04What is false sharing?ConcurrencyIntermediate
Two threads write to different variables that sit on the same cache line. The line bounces between cores and both threads slow down even though they share no data.
Fix it by aligning or padding hot variables to separate cache lines, typically 64 bytes, for example with alignas(64).
Q05Why avoid heap allocation on the hot path?PerformanceIntermediate
malloc and new can take locks, touch new pages and cause page faults, so their latency is unpredictable.
Pre-allocate at start-up and use object pools or arena allocators so the hot path never calls the general-purpose allocator.
Q06How do you measure latency correctly?MeasurementIntermediate
Report percentiles such as p50, p99 and p99.9, not the mean, and store results in a histogram.
Warm up first, pin threads to cores, use a steady clock or the TSC, and avoid coordinated omission, where a slow response delays the next measurement and hides the worst cases.
Q07Explain memory_order_acquire and memory_order_release.ConcurrencyAdvanced
A release store guarantees that all writes before it are visible to any thread that reads that value with an acquire load.
This is how a producer publishes data in a queue: write the slot, then release-store the new tail. The consumer acquire-loads the tail before reading the slot. It is cheaper than sequential consistency on many CPUs.
Q08How would you design a single-producer, single-consumer lock-free queue?DesignAdvanced
Use a fixed-size ring buffer with a power-of-two capacity so indexes wrap with a bit mask. Only the producer writes the tail and only the consumer writes the head, both as atomics using release on store and acquire on load.
Put head and tail on separate cache lines. The queue is full when tail − head equals capacity and empty when they are equal.
Q09What data structures would you use for a limit order book?TradingAdvanced
Keep bids and asks as price levels. Near the spread, an array indexed by price tick gives O(1) access, while a sorted map works for sparse prices.
Each level holds a FIFO queue of orders for price-time priority, and a hash map from order ID to order gives O(1) cancels and amends.
Also on its own page: Low-Latency C++ for Trading interview questions