logoalt Hacker News

nlylast Monday at 9:45 AM3 repliesview on HN

Burning CPU is preferable in some industries where latency is all that matters.


Replies

imtringuedlast Monday at 6:04 PM

Ok, but you do realize that you're now deep in the realm of real time Linux and you're supposed to allocate entire CPU cores to individual processes?

What I'm trying to express here is that the spinlock isn't some special tool that you pull out of the toolbox to make something faster and call it a day.

It's like a cryogenic superconductor that requires extreme caution to use properly. It's something you avoid doing because it's a pain in the ass.

show 1 reply
bob1029last Monday at 11:04 AM

Gaming and high frequency trading are the most obvious examples where this is desirable.

If you adjust the multimedia timer to its highest resolution (1ms on windows), sleeping is still a non-starter. Even if the sleep was magically 0ms whenever needed, you still have risk of context switching wrecking your cache and jacking up memory bandwidth utilization.

masklinnlast Monday at 11:06 AM

Even outside of such, if your contention is low and critical section short, spinning a few rounds to avoid a syscall is likely to be a gain not just in terms of latencies but also in terms of cycles waste.