3 ms·
Optimizing a Spin-Lock
- dalvrosa 1mo agoThanks for sharing! Happy to get feedback :) Note that I don't recommend spinlock for most cases, only when there is a 1:1 mapping between threads and phsycal CPU cores, and only after measuring
- hn45e7pbij 1mo agoOne thing I had to learn the hard way is that a spin lock is a bad fit the moment your threads can be preempted mid critical section. Under oversubscription you're spinning against a thread that isn't even scheduled.
- dalvrosa 1mo agoYeah that's quite right, you shouldn't be using spinlock without pinned threads