Hacker News new | past | comments | ask | show | jobs | submit login

Unsure what I'm more astonished about, that the correct case is that it would spin 29ms, or that a CPU instruction has changed it expected latency and prder of magnitude upwards.

I would expect any spinning lock to spin at most some slight fraction of the scheduling granularity, but almost always far less than the context switch time except maybe in some specific case of latency sensitive code.

Maybe thr long spin tine is for some reason trying to account for the very long scheduling quantas of windows server?

Superficially it seems misdirected in anything but real-time code since most schedulers would allow the thread to keep its quanta until the next scheduling if the thread wait time was low. The only case I can see this as not being the case is in a system that is overloaded and all CPU's have multiple threads that are all starved.




"Pause" spins give all their resources to the hyperthread-sibling. So unless the hyperthread-sibling is also stalled out for some reason, the "pause" instruction is definitely preferred.

So its not like resources are lost (at least, under high CPU utilization). But still, you're right in that a 29ms spin-lock sounds outrageous to me. That's definitely long.


Pause can be t he best choice even without hyperthreading because it can lower power utilization. And even on desktop that can mean less heat and more time for other stuff to run at a higher-clocked 'Turbo-boost'.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: