LockSupport.parkNanos() Under the Hood and the Curious Case of Parking (Part I)

When a colleague of mine was running some experiments, he noticed LockSupport.parkNanos() would either return almost immediately or in roughly 50 microseconds steps. In other words, calling LockSupport.parkNanos(10000) would not return after 10 microseconds but roughly after 50 μs. LockSupport.parkNanos(55000) would not return after 55 μs but roughly after 100 μs, etc. The 50 μs step was present way too consistently to be a coincidence. I was curious about what was causing it, and because I love exploring how stuff works under the hood, I decided to have a closer look.

Reproducer in Java

The first step was easy: write a reproducer. I re-used code from my older and somewhat-related experiment and just added a new runner: