summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authorChris HasiƄski <krzysztof.hasinski@gmail.com>2026-01-26 16:17:35 +0100
committerGitHub <noreply@github.com>2026-01-26 10:17:35 -0500
commit5add7c3ea9a13e657fc7cba78b2633b9548a55aa (patch)
treec060ff47045033a4063227bc039957877bac57aa /thread_pthread.c
parent2947aa41d4e6aa340edb0979c3e59bb6b6aca3a4 (diff)
Fix RUBY_MN_THREADS sleep returning prematurely (#15868)
timer_thread_check_exceed() was returning true when the remaining time was less than 1ms, treating it as "too short time". This caused sub-millisecond sleeps (like sleep(0.0001)) to return immediately instead of actually sleeping. The fix removes this optimization that was incorrectly short-circuiting short sleep durations. Now the timeout is only considered exceeded when the actual deadline has passed. Note: There's still a separate performance issue where MN_THREADS mode is slower for sub-millisecond sleeps due to the timer thread using millisecond-resolution polling. This will require a separate fix to use sub-millisecond timeouts in kqueue/epoll. [Bug #21836]
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 9c7754067b..542690eca0 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -2947,15 +2947,7 @@ timer_thread_check_signal(rb_vm_t *vm)
static bool
timer_thread_check_exceed(rb_hrtime_t abs, rb_hrtime_t now)
{
- if (abs < now) {
- return true;
- }
- else if (abs - now < RB_HRTIME_PER_MSEC) {
- return true; // too short time
- }
- else {
- return false;
- }
+ return abs <= now;
}
static rb_thread_t *