[ruby-cvs:66464] nagachika:r59286 (ruby_2_4): merge revision(s) 58284, 58812, 59028: [Backport #13632]

nagachika at ruby-lang.org nagachika at ruby-lang.org
Sat Jul 8 11:21:36 JST 2017

nagachika	2017-07-08 11:21:36 +0900 (Sat, 08 Jul 2017)

  New Revision: 59286


    merge revision(s) 58284,58812,59028: [Backport #13632]
    vm_core.h: ruby_error_stream_closed
    * vm_core.h (ruby_special_exceptions): renamed
      ruby_error_closed_stream as ruby_error_stream_closed, like the
    speed up IO#close with many threads
    Today, it increases IO#close performance with many threads:
      Execution time (sec)
      name            trunk   after
      vm_thread_close 4.276   3.018
      Speedup ratio: compare with the result of `trunk' (greater is better)
      name            after
      vm_thread_close 1.417
    This speedup comes because rb_notify_fd_close only scans threads
    inside rb_thread_io_blocking_region, not all threads in the VM.
    In the future, this type data structure may allow us to notify
    waiters of multiple FDs on a single thread (when using
    * thread.c (struct waiting_fd): declare
      (rb_thread_io_blocking_region): use on-stack list waiter
      (rb_notify_fd_close): walk vm->waiting_fds instead
      (call_without_gvl): remove old field setting
      (th_init): ditto
    * vm_core.h (typedef struct rb_vm_struct): add waiting_fds list
    * (typedef struct rb_thread_struct): remove waiting_fd field
      (rb_vm_living_threads_init): initialize waiting_fds list
    I am now kicking myself for not thinking about this 3 years ago
    when I introduced ccan/list in [Feature #9632] to optimize this
    same function :<
    IO#close: do not enqueue redundant interrupts (take #2)
    Enqueuing multiple errors for one event causes spurious errors
    down the line, as reported by Nikolay Vashchenko in
    This should fix bad interactions with test_race_gets_and_close
    in test/ruby/test_io.rb since we ensure rb_notify_fd_close
    continues returning the busy flag after enqueuing the interrupt.
    Backporting changes to 2.4 and earlier releases will be more
    * thread.c (rb_notify_fd_close): do not enqueue multiple interrupts
      [ruby-core:81581] [Bug #13632]
    * test/ruby/test_io.rb (test_single_exception_on_close):
      new test based on script from Nikolay

  Modified directories:
  Modified files:

More information about the ruby-cvs mailing list