On Mon, Oct 5, 2009 at 11:58 AM, Micah Martin <[email protected]> wrote:
> In a recent competition I held using JRuby
> (http://blog.8thlight.com/articles/2009/10/4/reflection-on-hangman), one of
> the competitors made a very interesting observation about the length of
> JRuby method names...
> "Actually I choose short method names because it was significantly faster in
> jruby. I think the speed increase was something like 10-20% on one letter
> method names."
> I found this a bit shocking.  How could that be true?

Largely we have callsite caching only for monomorphic call sites.  For
polymorphic sites we need to go look for the method which are stored
in ConcurrentHashMaps (one for each module/class).  The method names
are intern'd strings, but I suspect CHM does not optimize that away.
It does a full string compare to match on name.  That would be my
guess.  I am surprised it is that noticeable to tell the truth.

In MRI they generate an int value for all names and then use that for
method resolution which is why you would not see it in MRI.  Perhaps
we should reconsider how we store our methods.  We just need a nice
test case now :)

-Tom

-- 
blog: http://blog.enebo.com       twitter: tom_enebo
mail: [email protected]

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to