From: Wilson Bilkovich Date: 2006-12-09T01:23:30+09:00 Subject: Re: Rubinius interview with Evan Phoenix On 12/8/06, Sam Smoot wrote: > Since we're kinda on the topic of implementation I've got a question: > > Avi Bryant's article in response to JoelOnSoftware said you could get > method calls down to a jump and compare. > > My impression is that MRI basically uses hashtables for method lookup. > > Is it in the cards for Rubinius to receive the sort of optimizations > Avi was talking about? Is it reasonable to expect that an optimized > version of Rubinius could get method calls into the same performance > realm as c# or Java? > > This way I suppose C-Extensions would be used more as bridges to > leverage existing libraries, and not for performance reasons. > Yes. One way to do this is to make the common case as fast as possible, even if that assumption 'breaks' some of the dynamic features of Ruby. At runtime, you then detect when you've violated that assumption, trap the error, and re-evaluate the code in a slower mode. If you pick targets for that that don't trap very often, you can supposedly gain back quite a lot of speed. I believe the JVM has something like this for dynamic invocations, but I haven't looked at that code, so I might be making a fool out of myself by saying it.