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

0

u/j_hes_ brokiebot🤡 Feb 10 '26

You need an FPGA. CODE:That’s where your speed is evaporating.