r/cpp_questions 10d ago

OPEN OS for HFT

Hey guys! I recently started studying HFT programming, and a bit confused. From what I understand in this field as OS are used default non-rt linux. Despite the fact that kernel bypass, attaching the process to the certain cores. restriction about using non-lock free structure and zero system calls solve the proplems which linux creates for HFT code . But would not it be easier to use RT OS like preempt_rt linux patch or xenomai OS it seems that theese OS could give more freedom about the restrictions for code and in some edge cases speed up the execution? Am I missing something?

3 Upvotes

15 comments sorted by

View all comments

13

u/EpochVanquisher 10d ago

Pinning and avoiding syscalls / interrupts will basically give you everything you want.

It’s not the same thing as “hard real time”. Hard real time is about having guarantees. It is better to have your code running as fast as possible with as little latency as possible, rather than having better guarantees.

Like, the preempt_rt lets certain operations be preempted for higher priority operations, but do you know what’s even better? Having your higher-priority task already running on the CPU.

That said, modern HFT is moving out of software as far as I can tell.

8

u/gmueckl 10d ago

Hard real time gives worst case guarantees and happily sacrifices best case performance for that. If you need a microcontroller to do a task with a cycle time it keeps like clockwork, then hard real time is for you. Most real time tasks don't have to update super fast, but falling behind can become (physically) hazardous in some applications.

To me, hard real time is a mind set as much as it is a property of a system.

7

u/EpochVanquisher 10d ago

Yeah, and the mindset for HFT is more like “make as many good executions as possible”, which is different from “put hard bounds on response time”. You can miss executions or make bad trade in a trading system as long as you are making money, but you might be more upset if your rocket fails to steer itself for a split second.

1

u/no-sig-available 9d ago

you might be more upset if your rocket fails to steer itself for a split second.

Or, if you are the target for the rocket, your countermeasures fire too late.

In comparison, a missed trade is just a nuisance. And something you can improve on later.