Speedup Ruby on Linux

Origin: discussion on comp.lang.ruby

It appears that when compiled with --enable-pthread ruby will call sigprocmask MANY MANY more times than without. You can verify this with strace -c:

$ strace -c ruby -e '1.upto(100000) {|i| i.to_s}' 
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 99.65    1.462627           7    200006           sigprocmask

Solution:

  • From sources: --disable-pthread
  • For Gentoo:
# USE="-ipv6 -threads cjk" emerge ruby