Is this a good idea to increase performance?


#1

Charles, I know you have been working on Duby so you don’t keep having
to write Java code for JRuby. Theory is that static type perf is much
faster than for dynamic types.

I had a thought pop in my head. Would it be possible to somehow
annotate a method signature in Ruby code to allow the JVM to use
static typing? So instead of dropping to Java for performance
sensitive code, you could annotate the method and write the code in
Ruby.

So for

def blah(input1, input2, input3)

you could write

#jruby:type (String, String, Fixnum)
def blah(input1, input2, input3)

For regular ruby execution the annotation (which is just a comment)
would be ignored, but JRuby could use the info to optimize.

I have no idea what the implications are for this of course…

phil


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

phil swenson wrote:

Charles, I know you have been working on Duby so you don’t keep having
to write Java code for JRuby. Theory is that static type perf is much
faster than for dynamic types.

I had a thought pop in my head. Would it be possible to somehow
annotate a method signature in Ruby code to allow the JVM to use
static typing? So instead of dropping to Java for performance
sensitive code, you could annotate the method and write the code in
Ruby.

The idea has certainly crossed my mind, and I’ve even prototyped it. It
would definitely make a big difference compared to what we have now.
Basically what it would do is a single type check at the top of the
method, and subsequent calls would dispatch straight to that type. This
would immediately improve performance for core classes (since it would
dispatch straight to RubyFixnum#op_plus, for example) and could be
expanded to improve performance against other Ruby types (by just
dispatching directly to them without additional type checks).

It would also be useful as a simple type verification too.

I’m hoping that at some point we can move more of the compiler/optimizer
logic into Ruby so folks like you can play with it. But discussing
syntax etc right now would help move things along until that happens :slight_smile:

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email