Modern hardware scales by adding cores, but synchronization overhead increasingly limits scalability in user-space. Blocking locks are reliable but incur high handover costs due to frequent context switches. Spinlocks, in contrast, minimize handover latency, but their performance collapses in oversubscription (i.e., more threads than hardware contexts) as busy-waiting threads preempt lock holders in preemptible contexts. In an attempt to get the best of both worlds, many performance-oriented applications still rely on spin-then-park locks (e.g., POSIX mutexes). owever, like other locks that balance spinning and blocking, spin-then-park locks rely on arbitrary heuristics that often lead to suboptimal performance.
FlexGuard (SOSP'25) is a non-heuristic synchronization technique that leverages eBPF to monitor context switches and detect critical-section preemptions. When a lock holder is preempted, FlexGuard proactively transitions waiting threads from spinning to blocking, freeing CPU resources to quickly resume the preempted critical section. By reacting to actual execution events rather than static thresholds, FlexGuard can improve performance by up to 6 times compared to POSIX mutexes.
Another approach, often discussed in the Linux community (and used in Solaris), instead aims to prevent lock-holder preemptions altogether by extending scheduler time slices. Recent Linux proposals, including a patch by Thomas Gleixner (2025), use rseq to efficiently notify the kernel when a thread holds the lock. Rather than preempting such a thread, the scheduler allows it to run until the lock is released, preserving forward progress. Timeslice extensions have long been a subject of debate among maintainers.
To better understand whether timeslice extensions should be integrated into the Linux kernel, we evaluate both techniques across microbenchmarks and applications, including a memory-optimized database index, LevelDB, PARSEC's Dedup, and SPLASH2X's Raytrace and Streamcluster. Our results show that the two approaches address different bottlenecks and complement rather than replace each other, delivering benefits in both oversubscribed and non-oversubscribed settings.
Victor LAFORET