Hi,

We've been looking at Ruby performance on SPARC, and observed a 
potential significant performance gain for that platform (ie >10% in 
general).

Testing with test-all passes fine with the change, also inspecting the 
code it appears that the change is safe. However, there's we can find no 
test case as to why the code was written as it is.

The change is to remove the call to flush register windows from the 
EXEC_TAG and THREAD_SAVE_CONTEXT code.

This appears to be the point at which it was added to the code:
http://osdir.com/ml/lang.ruby.cvs/2003-01/msg00037.html

Here's the source code to Ruby 1.8.4 where this is still present:
http://ruby-doc.org/doxygen/1.8.4/eval_8c-source.html


Details:

The flush register windows instruction/trap causes all the register 
windows that are being held on the chip to be flushed out to memory. 
This is basically saving the call stack to memory.

It's necessary in situations where the program is going to switch 
contexts (otherwise the old context may not be stored correctly) and in 
situations where the elements in the registers are going to be inspected 
(eg for garbage collection).

The EXEC_TAG expression is a call to setjmp, which fits into neither of 
the above two classifications. Of course there is an issue with setjmp 
that there must be no variables live over the setjmp call, but flush 
register windows does not solve that particular problem.

EXEC_TAG gets called very frequently in Ruby, and the cost of doing the 
flush register windows is significant, so the application spends >10% of 
the runtime doing this.

The THREAD_SAVE_CONTEXT code also has a call to flush register windows, 
but one of the first things that the rb_thread_save_context code does is 
to call flush register windows. So the call does not seem to be necessary.

We have tested the code after removing these calls, and it runs 
significantly faster. However, I would like some kind of peer review and 
assistance in integrating these back into ruby core.

Is there anyone on these aliases who is able to help us get these 
performance improvements integrated.

Many thanks,

Darryl.
http://blogs.sun.com/d/




Reply via email to