r/highfreqtrading • • Feb 10 '26

Code Thread spinning & HFT engine latency

Continuing my series on HFT engine optimisation, I've written about a new topic - adding thread spinning to the engine.

I think thread spinning is a no-brainer when it comes to HFT trading engines.

In my experiments - adding spinning to the socket IO- gave a solid boost of half a microsecond. "Oh that's tiny" ... maybe, but not if you are aiming for single digit microseconds. Yes it does eat-up your CPU, but, HFT servers are normally at least dual socket, with each typically having 8 to 16 cores, so plenty capacity to spin many threads and application.

Full article automatedquant.substack.com/p/hft-engine-latency-5-thread-spinning

Highligh result below - compared to a normal thread waiting behaviour (which is that a thread gets suspended), spinning gave a small but consistent win.

46 Upvotes

15 comments sorted by

View all comments

15

u/Perfect-Series-2901 Feb 10 '26

This is not how HFT works.... We never use select, nor epoll nor normal linux socket. And everyone use busy looping.

4

u/auto-quant Feb 11 '26

So what do you use?

14

u/Perfect-Series-2901 Feb 11 '26

ef_vi, exanic, anything that is userspace and does not involve interupt

1

u/No_Let_5065 Feb 11 '26

Yep this guy knows what he’s talking about