Remix.run Logo
jcalvinowens 15 hours ago

> I feel like using spinlocks in user space at all without kernel support like rseq is just asking for weird performance degradations.

Yeah, exactly. "Doctor, help, somebody replaced my wooden hammer with a metal one, and now I can't hit myself in the face with it as many times."

If you use spinlocks in userspace, you're gonna have a bad time.

2 hours ago | parent | next [-]
[deleted]
mgaunard 11 hours ago | parent | prev [-]

Most people looking for performance will reach for the spinlock.

The expectation is that the kernel should somehow detect applications that are spinning, and avoid preempting them early.

silon42 21 minutes ago | parent | next [-]

If you are spinning so long that it requires preemption, you're doing something wrong, no?

jcalvinowens 14 minutes ago | parent [-]

It doesn't matter, it's a long tail thing: on average user spinlocks can work, and even appear to be beneficial on benchmarks. But if you have enough users, some of them will experience the apocalyptic long tail, no matter what you do: that's why user spinlocks are unacceptable.

IshKebab 11 hours ago | parent | prev [-]

Well that seems like an unreasonable expectation no? Also isn't the point of spinlocks that they get released before the kernel does anything? Otherwise you could just use a futex... Which maybe you should do anyway...

https://matklad.github.io/2020/01/04/mutexes-are-faster-than...