[ruby-cvs:70958] normal:r63867 (trunk): thread.c (ruby_ppoll): improve timespec to msec conversion

normal at ruby-lang.org normal at ruby-lang.org
Fri Jul 6 11:15:05 JST 2018

normal	2018-07-06 11:15:05 +0900 (Fri, 06 Jul 2018)

  New Revision: 63867


    thread.c (ruby_ppoll): improve timespec to msec conversion
    Round up non-zero <1ms timeouts to 1ms and use INT_MAX instead
    of infinite (-1) for extremely large timeouts.  All of our
    ppoll/select callers are able to handle spurious wakeups,
    This avoids excessive CPU usage and busy waits with short
    timeouts to rb_wait_for_single_fd.
    CPU usage with the following script is significantly reduced
    for systems with "#undef HAVE_PPOLL":
        require 'io/wait'
        r, w = IO.pipe
        Thread.new { loop { r.wait_readable(0.000001) } }.join(5)
    Low-resolution in poll(2) still sucks, though...
    Note: I don't see the value in making a similar change to
    time_timeval of a <1us sleep is attempted because of GVL
    release and syscall latency.

  Modified files:

More information about the ruby-cvs mailing list