Improved method analysis for Ruby performance by 30%

Source: Internet
Author: User
Tags join

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).

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.