Hi I've done a few easy things to try to speed up JRuby, when doing RDoc. I have three timings for you today. The first one is C Ruby doing it. The second is recent JRuby without my new enhancements, and the third is my final version right now:
[EMAIL PROTECTED] /cygdrive/d/project/jruby $ time ruby d:/programming/ruby/bin/gem install rake Attempting local installation of 'rake' Successfully installed rake, version 0.7.1 Installing RDoc documentation for rake-0.7.1... real 0m13.915s user 0m0.000s sys 0m0.000s [EMAIL PROTECTED] /cygdrive/d/project/jruby $ time bin/jruby.bat bin/gem install rake Attempting local installation of 'rake' Successfully installed rake, version 0.7.1 Installing RDoc documentation for rake-0.7.1... real 1m42.985s user 0m0.000s sys 0m0.010s [EMAIL PROTECTED] /cygdrive/d/project/jruby $ time bin/jruby.bat bin/gem install rake Attempting local installation of 'rake' Successfully installed rake, version 0.7.1 Installing RDoc documentation for rake-0.7.1... real 0m59.946s user 0m0.000s sys 0m0.010s As you can see, C Ruby does this in about 14s, old JRuby in 100s and my new version in 60s. For these purposes we are only 5 times slower than C Ruby, half a magnitude. =) So, what was the "error" in the former version? I'll let the code speak for itself. This is from RubyObject: public final int hashCode() { return RubyNumeric.fix2int(callMethod("hash")); } Yes, you read that right. We call a Ruby-method for EVERY HashMap#get, HashMap#put and HashSet#add etc... Not even a memoized version. And those operations are used fairly heavy in JRuby. HashMap#get is on the top 5 time thieves accord to hprof. So, I replaced the former with this in RubyObject: public int hashCode() { return toString().hashCode(); } and added very simple new ones to RubyArray.java RubyBignum.java RubyDir.java RubyFile.java RubyFixnum.java RubyHash.java RubyModule.java RubyString.java RubyThread.java RubyTime.java ... Right now my source tree is slightly unclean, so I can't give a patch for these modifications, but everyone of the is very simple. I just call hashCode on the value object inside the object most times. RubyModule uses classId == null ? 0 : classId.hashCode(); ... and RubyThread uses threadImpl.hashCode(). Regards Ola Bini _______________________________________________ Jruby-devel mailing list Jruby-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jruby-devel