We all know that you need to use the Configure--disable-pthread parameter when compiling ruby. Yes, configure--disable-pthread allows you to get about 30% performance improvements. But, what is this for?
All of this we need to use the Strace tool, this tool can play all the real operating system calls.
Here's a sample of the routines we tested:
def make_thread
thread.new {
a = []
10_000_000.times {
a << "a"
a.pop
}
}< C8/>end
t = make_thread
t1 = make_thread
t.join
t1.join
If we use the Strace tool to test the Configure--enable-pthread version of the Ruby engine, we can get the following results:
22:46:16.706136 Rt_sigprocmask (Sig_block, NULL, [], 8) = 0 <0.000004>
22:46:16.706177 rt_sigprocmask (sig_ block, null, [], 8 = 0 <0.000004>
22:46:16.706218 rt_sigprocmask (Sig_block, NULL, [], 8) = 0 <0.000004>
22:46:16.706259 rt_sigprocmask (Sig_block, NULL, [], 8) = 0 <0.000005>
22:46:16.706301 rt_sigprocmask ( Sig_block, NULL, [], 8 = 0 <0.000004>
22:46:16.706342 rt_sigprocmask (Sig_block, NULL, [], 8) = 0 <0.000004 >
22:46:16.706383 rt_sigprocmask (Sig_block, NULL, [], 8) = 0 <0.000004>
You'll find that the sigprocmask system calls up and down one page after another. If you use Strace-c, you will find altogether about 20,054,180 Sigprocmask system calls. However, if you are running in the ruby version of--disable-pthread, you will find that there are not so many sigprocmask system calls (only 3 times, which is a very different thing).