From: Paul van den Bogaard Date: 2008-10-30T23:50:17+09:00 Subject: [ruby-core:19634] performance issues with --enable-pthread on Solaris. --Boundary_(ID_T+cO1d2G8ms7BBOoeFcvLg) Content-type: text/plain; delsp=yes; format=flowed; charset=US-ASCII Content-transfer-encoding: 7BIT Introduction ------------ We are experiencing performance issues when running ruby. That is if this binary was created with the --enable-pthread option. Executing these tests with ruby 1.8.7 does not show this performance degradation. This made me compare the sources of both ruby versions. Since it was soon obvious that there was a strong relation between this degradation and the set/getcontext functions I focussed on where these two functions were used. This happens to be the case in eval.c In this file I found __builting_setjmp and __builtin_longjmp being used in 1.8.7. But not in 1.8.6. Besides that it also turned out that the use of both xxxcontext functions was triggered by a #define in config.h. Source code changes and results ------------------------------- The following tests were done with: ruby runner.rb -b BinaryTrees in different settings. Both on a SPARC IV 1350MHz V890 box (16 cores) and a V20Z (4 cores AMD), and a 8 core AMD 4600 The results are (total time reported): Name_____ThreadChoice_____ SPARC IV_____V20Z______4600___ baseline --disable-pthread 25.02 8.63 7.15 basethread --enable-pthread 43.67 26.76 11.71 editConfig --enable-pthread 25.33 8.62 7.32 builtin --enable-pthread 26.38 8.71 7.31 builtinFlush --enable-pthread 24.58 8.62 7.29 OS used: SPARC IV: 5.11 snv_79a 4600: 5.11 snv_70b V20Z: 5.11 snv_86 All binaries were configured with the following flags: ./configure --disable-shared CC=cc "CFLAGS=-O4 -g -v - V -DRUBY_EXPORT" --prefix=$HOME/ Ruby version: 1.8.6 p286 The baseline and basethread and editConfig version used the source without modification. The others had some tweaks in the file eval.c editConfig: after running configure the following lines were removed from config.h: #define HAVE_GETCONTEXT 1 #define HAVE_SETCONTEXT 1 Both builtin and builtinFlush had the following two lines (depicted by <----------) added: > #else > # if !defined(setjmp) && defined(HAVE__SETJMP) > # define ruby_setjmp(just_before_setjmp, env) \ > ((just_before_setjmp), _setjmp(env)) > # define ruby_longjmp(env,val) _longjmp(env,val) > # else > # define ruby_setjmp(just_before_setjmp, env) \ > ((just_before_setjmp), setjmp(env)) > # define ruby_longjmp(env,val) longjmp(env,val) > # endif > #endif > > #define ruby_setjmp(a,b) > __builtin_setjmp(b) <------------- > #define ruby_longjmp(a,b) > __builtin_longjmp(a,b) <------------- > > #include > #include > #include > BuiltinFlash has a different definition for a macro. The following macro: #define EXEC_TAG() (FLUSH_REGISTER_WINDOWS, ruby_setjmp(((void)0), prot_tag->buf)) is redefined in BuiltinFlash by (as found in the 1.8.7 source) : #define EXEC_TAG() (ruby_setjmp(((void)0), prot_tag->buf)) These are all runs on dedicated systems. Nothing else running besides the standard background processes. Stability --------- I ran make test-all to see if these changes would break anything. This seems not to be the case. Request ------- I would like to hear from the community if these changes would be acceptable. And if there is a preference for one of them. Any further insight, recommendation or feedback is, of course, welcome. Thanks, Paul --------------------------------------------------------------------------------------------- Paul van den Bogaard Paul.vandenBogaard@sun.com ISV-E -- ISV Engineering, Opensource Engineering group Sun Microsystems, Inc phone: +31 334 515 918 Saturnus 1 extentsion: x (70)15918 3824 ME Amersfoort mobile: +31 651 913 354 The Netherlands fax: +31 334 515 001 --Boundary_(ID_T+cO1d2G8ms7BBOoeFcvLg) Content-type: text/html; charset=US-ASCII Content-transfer-encoding: QUOTED-PRINTABLE
Introduction
<= div>-------= -----

We are experiencing performance is= sues when running ruby. That is if this binary was created with the -= -enable-pthread option.  Executing these tests with ruby 1.8.7 d= oes not show this performance degradation. 
This made me = compare the sources of both ruby versions. Since it was soon obvious = that there was a strong relation between this degradation and the set= /getcontext functions I focussed on where these two functions&nb= sp;were used. This happens to be the case in eval.c
In this file I found  __builting_setjmp and __bu= iltin_longjmp being used in 1.8.7. But not in 1.8.6.
Be= sides that it also turned out that the use of both xxxcontext functio= ns was triggered by a #define in config.h. 
<= div>


Source code changes = and results
-------------------------------

The following tests were done with:

ruby runner.rb -b BinaryTrees

in diff= erent settings. Both on a SPARC IV 1350MHz V890 box (16 cores) and a = V20Z (4 cores AMD), and a 8 core AMD 4600

The results are (tot= al time reported):

Name_____ThreadChoice_____ SPARC IV_____V20= Z______4600___
baseline      --disable-pt= hread           25.= 02            =   8.63         &nbs= p;   7.15
basethread --enable-pthread   &= nbsp;        43.67  &nbs= p;         26.76  &= nbsp;        11.71
editCon= fig   --enable-pthread       =      25.33      &nb= sp;       8.62    &= nbsp;        7.32
builtin =          --enable-pthrea= d            2= 6.38           &nbs= p;  8.71         &n= bsp;   7.31
builtinFlush --enable-pthread  &nb= sp;         24.58  =            &nb= sp;8.62           &= nbsp; 7.29

OS used:

SPARC IV:   5.11 snv= _79a
4600:          &= nbsp;5.11 snv_70b
V20Z:        =    5.11 snv_86

All binaries were configured wit= h the following flags:

./configure <thread choise> --disabl= e-shared CC=3Dcc "CFLAGS=3D-O4 -g -v -V -DRUBY_EXPORT" --prefix=3D$HO= ME/<name>

Ruby version: 1.8.6 p286

Th= e baseline and basethread and editConfig version used the source with= out modification.
The others had some tweaks in the file eval.c
editConfig: after running configure the following lines were rem= oved from config.h:

#define HAVE_GETCONTEXT 1
#define HAVE_= SETCONTEXT 1


Both builtin and builtinFlush had the followi= ng two lines (depicted by <----------)  added:

=
#else
#  if !defined(setjmp) && defined(HAVE__SETJMP)
<= /span>
#    define r= uby_setjmp(just_before_setjmp, env) \
<= blockquote type=3D"cite">       ((just_before_setj= mp), _setjmp(env))
#=    define ruby_longjmp(env,val) _longjmp(env,val)
=
#  else
#    define ruby_setjmp= (just_before_setjmp, env) \
      ((just_before_setjmp), setjm= p(env))
#   &n= bsp;define ruby_longjmp(env,val) longjmp(env,val)
#  endif
#endif
<= br>
#define ruby_setjmp(= a,b)    __builtin_setjmp(b)     &n= bsp;           = ;           &n= bsp;    <-------------
#define ruby_longjmp(a,b) __builtin_longjmp(a,b= )            &= nbsp;          &nbs= p;     <-------------

#include <sys/types.h>
#include <errno.h>


BuiltinFlash has a different definition= for a macro. The following macro:

#define EXEC_TAG()  &n= bsp; (FLUSH_REGISTER_WINDOWS, ruby_setjmp(((void)0), prot_tag->b= uf))

is redefined in BuiltinFlash  by (as found in the 1.= 8.7 source) :

#define EXEC_TAG()    (ruby_setjm= p(((void)0), prot_tag->buf))

These are all runs on dedicated s= ystems. Nothing else running besides the standard background processe= s.


Stability
--= -------

I ran make test-all = to see if these changes would break anything. This seems not to be th= e case.


Request
<= span class=3D"Apple-style-span" style=3D"font-size: 11px;">-------

I would like to hear from the community = if these changes would be acceptable. And if  there is a prefere= nce for one of them. 
Any further insight, recommen= dation or feedback is, of course, welcome.

Paul



-------------------= ---------------------------------------------------------------------= -----
Paul van den Bogaard       &nb= sp;           =            &nb= sp;
Paul.vandenBogaar= d@sun.com
ISV-E  -- ISV Engineering, Opensource Engine= ering group

Sun Microsystems, Inc     &nbs= p;           &= nbsp;          &nbs= p; phone:        +31 334 515 = 918
Saturnus 1         &nb= sp;           =            &nb= sp;           =      extentsion: x (70)15918
3824 ME Amer= sfoort           &n= bsp;           = ;          mobile: =       +31 651 913 354
The Netherland= s            &= nbsp;          &nbs= p;           &= nbsp;    fax:       = ;     +31 334 515 001

<= /div>
--Boundary_(ID_T+cO1d2G8ms7BBOoeFcvLg)--