You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With an absolute timeout, the call would have returned immediately because the deadline is already in the past.
The reason libuv uses pthread_cond_timedwait_relative_np() is because macOS at the time didn't support pthread_condattr_setclock(CLOCK_MONOTONIC) but I'm fairly sure macOS >= 11 does.
The text was updated successfully, but these errors were encountered:
Before this commit, libuv used pthread_cond_timedwait_relative_np() on
macOS out of necessity, because that platform did not support absolute
timeouts back when uv_cond_timedwait() was added.
Absolute timeouts are oblivious to preemption. Relative timeouts on the
other hand suffer from skew when preempted between computing the timeout
and waiting, because the thread ends up waiting longer than it needs to.
Libuv's API uses relative timeouts and is therefore not immune to that
issue but this commit should make it less bad and make libuv on macOS
align more closely with other platforms.
Fixes: libuv#4372
Libuv's
uv_cond_timedwait()
usespthread_cond_timedwait()
with an absolute timeout on most Unices butpthread_cond_timedwait_relative_np()
on macOS.On the one hand, relative timeouts are more efficient because there's no need to query the current system time first.
On the other hand, relative timeouts block too long if the thread is preempted at an inopportune time, impacting performance:
With an absolute timeout, the call would have returned immediately because the deadline is already in the past.
The reason libuv uses
pthread_cond_timedwait_relative_np()
is because macOS at the time didn't supportpthread_condattr_setclock(CLOCK_MONOTONIC)
but I'm fairly sure macOS >= 11 does.The text was updated successfully, but these errors were encountered: