Some notes on performance exploration. Most of this is based on my belief that our core interpreter and the core native types (strings, symbols, fixnums, etc) are a large source of our performance woes. C Ruby is able to use extremely lightweight structs for most of these core types, and runs blazing fast (order of magnitude faster in many cases).

- Caching of all literal fixnums

I tested this by holding Long objects in the AST and adding a cache to the runtime. The results were not terribly promising, and only showed marginal gains.
Tested with:
t = Time.now; 1_000_000.times { 1000; 2000; 3000; 4000; }; p Time.now - t
Before cache: 5.15s avg
After cache: 4.7s avg, 8% improvement

- Caching of all literal floats

Same solution as above, but better results.
Before cache: 18.2s avg
After cache: 5.2s avg, 71% improvement

...However it seems unlikely that literal floats are a common performance problem. On the other hand, Floats are so drastically slow without caching I have to wonder if something's amiss.

- Disable ObjectSpace

I started tracing through our object creation versus Ruby's, and along the way thought I'd try disabling ObjectSpace entirely. The results were surprising.
Tested with:
t = Time.now; 1_000_000.times { '1000'; '2000'; '3000'; '4000'; }; p Time.now - t
Before disabling: 15.65s avg
After disabling: 5.76s avg, 64% improvement

Now we're getting somewhere. Our ObjectSpace appears to be a source of some severe performance issues. That needs to be addressed.

...

In general, I think there's a lot of performance to be gained from very small tweaks to the core interpreter and classes. Something as simple as removing the add of an object to ObjectSpace gives a 64% improvement in speed; minor caching tweaks can produce similar results. As a whole, each of these little fixes and tweaks will very quickly add up.

--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com
_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel

Reply via email to