Hi,

Yes, of course that's needed. But on the other hand, the change actually
already found us a place where our test code was wrong (see my post on
TestRubyHash). Incidentally, my first approach was to try and see how
System.identityHashCode() would work out as the general
hashCode-algorithm. I've been using rubygems setup, gem install and the
rails script as different tests to see if the changes break anything,
and it was very apparent when I changed to identityHashCode that nothing
at all worked. With my current changes everything seems really fine, though!

/O

----- Original Message -----
From: Charles O Nutter <[EMAIL PROTECTED]>
Date: Sunday, June 18, 2006 6:22 am
Subject: Re: [Jruby-devel] JRuby, RDoc and speed...
To: jruby-devel@lists.sourceforge.net

> This is pretty promising; we need to do an audit of how all the 
> core objects
> are used in various places, however, especially in our 
> implementation of
> Ruby's hash, so we're not breaking anything; but it has always 
> bothered me
> that java's hashCode and Ruby's hash were synonymous in JRuby. This 
> lookslike a good first step, and ought to help performance in a 
> number of places.
> 
> On 6/17/06, Ola Bini <[EMAIL PROTECTED]> wrote:
> >
> > 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
> >
> 
> 
> 
> -- 
> 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