ruby-changes:51473
From: normal <ko1@a...>
Date: Sun, 17 Jun 2018 12:27:50 +0900 (JST)
Subject: [ruby-changes:51473] normal:r63683 (trunk): thread_pthread.c: microptimize vm->gvl.waiting checks
normal 2018-06-17 12:27:45 +0900 (Sun, 17 Jun 2018) New Revision: 63683 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63683 Log: thread_pthread.c: microptimize vm->gvl.waiting checks "gvl.waiting" is volatile, so the compiler won't perform these optimizations for us. Modified files: trunk/thread_pthread.c Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 63682) +++ thread_pthread.c (revision 63683) @@ -73,8 +73,7 @@ gvl_acquire_common(rb_vm_t *vm) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L73 { if (vm->gvl.acquired) { - vm->gvl.waiting++; - if (vm->gvl.waiting == 1) { + if (!vm->gvl.waiting++) { /* * Wake up timer thread iff timer thread is slept. * When timer thread is polling mode, we don't want to @@ -87,7 +86,7 @@ gvl_acquire_common(rb_vm_t *vm) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L86 rb_native_cond_wait(&vm->gvl.cond, &vm->gvl.lock); } - vm->gvl.waiting--; + --vm->gvl.waiting; if (vm->gvl.need_yield) { vm->gvl.need_yield = 0; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/