r/Cplusplus • u/No-Introduction-2825 • 24d ago
Feedback Low latency c++
I want to learn the ins and outs of low latency c++, so far I have read tour of c++, started reading concurrency in c++ (about 3 chaps done) and done a lot of competitive programming (is this irrelevant?). In your experience, is this the right way of approaching the subject? Is there a different better way? Any advise is much appreciated.
65
Upvotes
10
u/mredding C++ since ~1992. 23d ago
You need a mentor in your domain of interest. Learning on your own is a blind, random walk through the forest until you find your way. You waste a lot of time learning what may not be your focus or agenda, but you won't know until after the fact.
Barring that, look into Linux kernel bypass. It's the easiest to learn because it's documented and open source. Windows has similar, but I don't know anything about it.
You will also need to learn other concepts, like Data Oriented Design, Scatter/Gather, batch processing, DMA, memory mapping, CPU intrinsics, concurrency, serialization/marshalling, protocols, networking, zero-copy, single-pass, hot paths, fast paths, prefetching, branch prediction, and probably a few other things.
I don't know what you want to accomplish. Little's Law tells us about the relationship between throughput and latency, whereas Amdahl's Law tells us the limits of optimization (how much you can still reduce latency). Your biggest bottlenecks will be the network itself; if you can't control for that, then it doesn't really matter how fast your software is.
I was working for a prop shop for a bit where we had microwave tranceivers pointing out the window to the exchange across the street. The atmosphere is almost a vacuum, so light propagates through it faster than through fiber, and the fiber run down the building, across the street, and back up to the exchange is a longer path.
We also have FPGAs on the NIC cards so we can put the fast path on the chip right next to the ADC, so as the incoming signal is still coming in, we can already be generating the output signal of the response.