[#23457] [Bug #1471] "Mutual join" deadlock detection faulty in 1.8.6 and 1.8.7 — John Carter <redmine@...>

Bug #1471: "Mutual join" deadlock detection faulty in 1.8.6 and 1.8.7

17 messages 2009/05/15

[#23483] [Bug #1478] Ruby archive — Oleg Puchinin <redmine@...>

Bug #1478: Ruby archive

29 messages 2009/05/16
[#29225] [Feature #1478] Ruby archive — Luis Lavena <redmine@...> 2010/04/02

Issue #1478 has been updated by Luis Lavena.

[#30345] Re: [Feature #1478] Ruby archive — "NAKAMURA, Hiroshi" <nakahiro@...> 2010/05/21

On Fri, Apr 2, 2010 at 17:13, Luis Lavena <redmine@ruby-lang.org> wrote:

[#30346] Re: [Feature #1478] Ruby archive — Jonathan Nielsen <jonathan@...> 2010/05/21

> Thanks for your comment.

[#30347] Re: [Feature #1478] Ruby archive — Jonathan Nielsen <jonathan@...> 2010/05/21

OK Hiroshi, I read some of the comments earlier in the thread that I

[#30355] Re: [Feature #1478] Ruby archive — Caleb Clausen <vikkous@...> 2010/05/21

On 5/20/10, Jonathan Nielsen <jonathan@jmnet.us> wrote:

[#30364] Re: [Feature #1478] Ruby archive — Benoit Daloze <eregontp@...> 2010/05/22

Hi,

[#23505] [Bug #1494] tempfile#unlink may silently fail on windows — Nicholas Manning <redmine@...>

Bug #1494: tempfile#unlink may silently fail on windows

19 messages 2009/05/19

[#23572] [Bug #1525] Deadlock in Ruby 1.9's VM caused by ConditionVariable.wait and fork? — Hongli Lai <redmine@...>

Bug #1525: Deadlock in Ruby 1.9's VM caused by ConditionVariable.wait and fork?

27 messages 2009/05/27

[#23595] Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...>

The RUBY_PLATFORM constant is documented in the latest Pickaxe as "The

17 messages 2009/05/28
[#23596] Re: Meaning of RUBY_PLATFORM — Luis Lavena <luislavena@...> 2009/05/28

On Thu, May 28, 2009 at 3:41 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#23602] Re: Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...> 2009/05/28

On Thu, May 28, 2009 at 2:52 PM, Luis Lavena <luislavena@gmail.com> wrote:

[#23608] Re: Meaning of RUBY_PLATFORM — Luis Lavena <luislavena@...> 2009/05/28

On Thu, May 28, 2009 at 7:08 PM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#23609] Re: Meaning of RUBY_PLATFORM — Rick DeNatale <rick.denatale@...> 2009/05/29

On Thu, May 28, 2009 at 7:22 PM, Luis Lavena <luislavena@gmail.com> wrote:

[ruby-core:23352] [PATCH] Fixing poor performance with --enable-pthread on Ruby 1.8

From: Joe Damato <ice799@...>
Date: 2009-05-04 02:19:53 UTC
List: ruby-core #23352
Hi -

I'm using Linux on an x86_64 and Ruby 1.8.7.

It is common knowledge that when building Ruby with --enable-pthread,
Ruby generates a huge number of calls to sigprocmask. When you
configure Ruby with --disable-pthread, this does not happen.

For example:
[joe@pluto:/home/joe/ruby-github]% strace -ttT ./miniruby test.rb 2>&1
| grep sigprocmask
14:53:55.918258 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 <0.000006>
14:53:55.918717 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 <0.000005>
14:53:56.915505 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 <0.000006>
14:53:56.915787 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 <0.000005>
14:53:56.915819 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0 <0.000005>
....

The reason for this seems to be a bug in configure.in.

If configure is run with --enable-pthread, configure decides to enable
[sg]etcontext. getcontext is then called for handling context switches
and for EXEC_TAG. [sg]etcontext save/restore the signal mask when they
are invoked.

On my x86_64 system, configure selects _setjmp/_longjmp when I disable
[sg]etcontext. _setjmp/_longjmp do -not- save and restore the signal
mask. So, when I disable [sg]etcontext I get a performance boost
because I am using _setjmp/_longjmp which do not make all the extra
calls to sigprocmask.

After applying the patch below adds a new configure switch
"--disable-ucontext" after applying the patch you can:

./configure --disable-ucontext --enable-pthread

To produce a version of Ruby that uses the pthread as a timer without
incurring a huge performance loss.

With the patch applied, Ruby built with "--disable-pthread" and
"--enable-pthread --disable-ucontext" have approximately equivalent
performance.

I have included a test script, performance output, and the patch I am
using below.

Thanks,
Joe Damato

Here is a quick performance test:

test.rb:
sleep 1
t = Thread.new {
 a = []
 10_000_000.times {
   a << "a"
   a.pop
 }
}

t1 = Thread.new {
 a = []
 10_000_000.times {
   a << "b"
   a.pop
 }
}
t.join
t1.join

simple performance measurement:

./configure --enable-pthread:

[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  10.89s user 2.17s system 92% cpu 14.134 total
[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  10.70s user 2.31s system 92% cpu 14.037 total
[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  10.74s user 2.22s system 92% cpu 13.995 total

./configure --disable-pthread:

[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  8.70s user 0.00s system 89% cpu 9.734 total
[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  8.72s user 0.01s system 89% cpu 9.750 total
[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  8.69s user 0.00s system 89% cpu 9.729 total

./configure --enable-pthread --disable-ucontext:

[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  8.62s user 0.01s system 89% cpu 9.674 total
[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  8.63s user 0.00s system 89% cpu 9.647 total
[joe@pluto:/home/joe/ruby-github]% time ./miniruby test.rb
./miniruby test.rb  8.74s user 0.00s system 89% cpu 9.765 total

diff --git a/configure.in b/configure.in
index d922bd2..5815c40 100644
--- a/configure.in
+++ b/configure.in
@@ -368,6 +368,10 @@ AC_ARG_WITH(libc_r,
       *)   with_libc_r=no;;
       esac], [with_libc_r=no])

+AC_ARG_ENABLE(ucontext,
+       [  --disable-ucontext      do not use getcontext()/setcontext().],
+       [disable_ucontext=yes], [disable_ucontext=no])
+
 AC_ARG_ENABLE(pthread,
       [  --enable-pthread        use pthread library.],
       [enable_pthread=$enableval], [enable_pthread=no])
@@ -1038,7 +1042,8 @@ if test x"$enable_pthread" = xyes; then
       fi
    fi
 fi
-if test x"$ac_cv_header_ucontext_h" = xyes; then
+
+if test x"$ac_cv_header_ucontext_h" = xyes && test
x"$disable_ucontext" = xno; then
    if test x"$rb_with_pthread" = xyes; then
       AC_CHECK_FUNCS(getcontext setcontext)
    fi

In This Thread

Prev Next