From: Motohiro KOSAKI Date: 2010-06-20T23:05:32+09:00 Subject: [ruby-core:30835] [Bug #2553] Fix pthreads slowness by eliminating unnecessary sigprocmask calls Issue #2553 has been updated by Motohiro KOSAKI. ruby 1.8.8 have the same issue. $ autoconf && ./configure --disable-pthread && make $ time ./ruby -ve '1_000_000.times { x = 2 ** 256 }' ruby 1.8.8dev (2010-06-15) [x86_64-linux] real 0m1.176s user 0m1.171s sys 0m0.005s $ autoconf && ./configure --enable-pthread && make [kosaki@kosaopt ruby_1_8]$ time ./ruby -ve '1_000_000.times { x = 2 ** 256 }' ruby 1.8.8dev (2010-06-15) [x86_64-linux] real 0m1.513s user 0m1.340s sys 0m0.173s $ strace -c ./ruby -e '1_000_000.times { x = 2 ** 256 }' % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 99.98 0.160160 0 1000011 rt_sigprocmask 0.02 0.000025 2 14 mprotect 0.00 0.000000 0 8 read 0.00 0.000000 0 19 10 open 0.00 0.000000 0 9 close 0.00 0.000000 0 4 3 stat 0.00 0.000000 0 9 fstat 0.00 0.000000 0 26 mmap 0.00 0.000000 0 1 munmap 0.00 0.000000 0 7 brk 0.00 0.000000 0 14 rt_sigaction 0.00 0.000000 0 1 1 access 0.00 0.000000 0 1 execve 0.00 0.000000 0 6 getrlimit 0.00 0.000000 0 1 getuid 0.00 0.000000 0 1 getgid 0.00 0.000000 0 2 geteuid 0.00 0.000000 0 2 getegid 0.00 0.000000 0 1 arch_prctl 0.00 0.000000 0 2 1 futex 0.00 0.000000 0 1 set_tid_address 0.00 0.000000 0 1 set_robust_list ------ ----------- ----------- --------- --------- ---------------- 100.00 0.160185 1000141 15 total summary of ruby_1_8 code node.h ------------------------------------------ #if defined(HAVE_GETCONTEXT) && defined(HAVE_SETCONTEXT) #include #define USE_CONTEXT #endif #include #include "st.h" The syscam can use getcontext(), USE_CONTEXT is always set. eval.c ------------------------------------------ #ifdef USE_CONTEXT (snip) # define ruby_setjmp(just_before_setjmp, j) ((j)->status = 0, \ (just_before_setjmp), \ PRE_GETCONTEXT, \ getcontext(&(j)->context), \ POST_GETCONTEXT, \ (j)->status) if USE_CONTEXT is defined, ruby_setjmp() mean to call getcontext(). and linux getcontext() implementation call rt_sigprocmask() internally. ---------------------------------------- http://redmine.ruby-lang.org/issues/show/2553 ---------------------------------------- http://redmine.ruby-lang.org