C++ Logo


Advanced search

Properties of HFT compared to other low-latency use cases

From: Timur Doumler <cpp_at_[hidden]>
Date: Mon, 3 Oct 2022 18:24:06 +0300
Hi SG14,

For a presentation this Thursday, I am currently comparing different use cases of low-latency programming, in particular video games, audio processing, and high frequency trading, and specifically the properties of the low-latency "hot path" for these use cases. I don't know much about HFT, so perhaps some experts here could answer a few questions? It would be immensely helpful.

- Typical time scales. In gaming, the deadline is typically one frame (~ 16 ms with 60 fps). In audio, it's typically the length of an audio buffer (~ 1–5 ms depending on the audio settings). Is it correct that HFT deals with much shorter timescales, i.e. you care about microseconds and even nanoseconds? What's the typical timescale?

- Nature of deadline. In audio and gaming, as long as you meet the deadline to generate one video frame/audio buffer, you're good, for example it typically doesn't matter if something takes 1.0 ms or 1.1 ms, as long as it *never* takes more than that. Is it correct that in HFT, it *does* matter? There's not so much a hard deadline, but more like the faster, the better, and reducing the operation by another microsecond is always desirable?

- What happens if deadline is not met. In audio, you get an audible glitch, which is very bad. In video games, you drop a frame, which is sometimes noticeable and not desirable. What about HFT? What's the typical cost of being too slow?

- "Topology" of the hot path. In audio, the "hot path" is a callback (controlled by the sound card + driver + OS kernel) coming in regular time intervals on a single dedicated audio processing thread. In video games, the "hot path" can be multiple threads, all dedicated to rendering. What about HFT? Is the hot path on a single thread? On multiple threads? Who calls this thread, how often, and under what circumstances? Is the hot path being called in regular intervals or following some kind of external event?

- What is the input and output of the hot path? In audio, the input is typically audio data or maybe MIDI data, and the output is more audio data. In video games, the input for the hot path the current state of the world, and the output is video frames. What is typically the input and output of the hot path in HFT?

- Concurrency. How does the hot path typically exchange data with other threads and the rest of the program? Atomics? Lock-free data structures? Something else?

I'd be very grateful for any insights you can give me!


P.S. I deliberately excluded embedded for now because it's such a diverse field that it's impossible to characterise as a whole: you have superloops, interrupt-driven flows, real-time operating systems and much more...

Received on 2022-10-03 15:24:08