31 messages in org.codehaus.groovy.devRe: [groovy-dev] as usual on performa...
FromSent OnAttachments
Alex Tkachman27 Feb 2008 05:38 
Guillaume Laforge27 Feb 2008 05:47 
Alex Tkachman27 Feb 2008 06:01 
Chanwit Kaewkasi27 Feb 2008 06:21 
Martin C. Martin27 Feb 2008 06:28 
Jochen Theodorou27 Feb 2008 06:32 
Jochen Theodorou27 Feb 2008 06:33 
tugwilson27 Feb 2008 06:56 
Chanwit Kaewkasi27 Feb 2008 07:16 
Chanwit Kaewkasi27 Feb 2008 08:02 
Jochen Theodorou27 Feb 2008 08:28 
tugwilson27 Feb 2008 09:00 
tugwilson27 Feb 2008 09:56 
Chanwit Kaewkasi27 Feb 2008 11:28 
Chanwit Kaewkasi27 Feb 2008 11:31 
Jochen Theodorou27 Feb 2008 11:36 
Alex Tkachman27 Feb 2008 11:59 
Martin C. Martin27 Feb 2008 12:19 
Jochen Theodorou27 Feb 2008 12:37 
Jochen Theodorou27 Feb 2008 12:45 
tugwilson27 Feb 2008 12:48 
tugwilson27 Feb 2008 12:52 
Martin C. Martin27 Feb 2008 13:27 
Alex Tkachman27 Feb 2008 13:49 
tugwilson27 Feb 2008 14:15 
Jochen Theodorou27 Feb 2008 17:10 
Alexandru Popescu ☀27 Feb 2008 17:38 
Charles Oliver Nutter28 Feb 2008 00:20 
Jochen Theodorou28 Feb 2008 01:33 
Alexandru Popescu ☀28 Feb 2008 02:56 
tugwilson28 Feb 2008 03:29 
Subject:Re: [groovy-dev] as usual on performance - operations on primitives
From:Jochen Theodorou (blac@gmx.org)
Date:02/27/2008 08:28:45 AM
List:org.codehaus.groovy.dev

Chanwit Kaewkasi schrieb:

Hi Jochen,

On 27/02/2008, Jochen Theodorou <blac@gmx.org> wrote:

how much more than using a normal Java class can there be to provide more type information? What kind of type information does the JIT need?

I probably used wrong words. The type information is there. But Groovy has no mechanism to *feed them back* because there is no something like interpreter in Groovy. I think this is by-design. MOP layer does its job only for dispatching methods.

So you mean a custom JIT, no the JIT of the JVM.

To boost the performance to be as fast as using primitives, I think it's needed to add some profiling technique to collect and utilize type information at runtime.

For example,

def myMethod() { def b = 10 def a = b + 2 }

compiles to

Class class1 = org.codehaus.groovy.trace.Demo.class; Class class2 = groovy.lang.MetaClass.class; Object b = new Integer(10); Object a = ScriptBytecodeAdapter.invokeMethodN(class1, b, "plus", new Object[] { new Integer(2) });

By using my human eyes, I can see that 'b' is an integer. But during the execution, no one knows its type because. Then, when invoking "plus", we can know that it is called for an integer by trapping invokeMethodN, but we never know that it's 'b'.

you can get that knowledge by a flow analysis I think.

I think if we can trace along these 2 expressions, we then can create equivalent set of bytecodes for them using primitives, and execute the new generated codes next time this method is executed.

Is it feasible ?

this means you have either to change the code the method uses, or you have to generate code and plug that in here. But ignoring this.. The question could for example if we need a JIT here at all? we could also generate static code and add a check. Something like (pseudocode):

Object a,b; if (Integer#plus(Integer) is default) { int b' = 10 int a' = b'+2 b = new Integer(b') a = new Integer(a') } else { Class class1 = org.codehaus.groovy.trace.Demo.class; b = new Integer(10); a = ScriptBytecodeAdapter.invokeMethodN(class1, b, "plus", new Object[] { new Integer(2) }); }

If I wanted to JIT then I would probably try to inline the bytecode of the called method and eliminate unneeded boxing action and transformations. For example I could find, that the call is ultimatively only:

return new Integer(left.intValue() + right.intValue());

which means I could reduce the code to:

Class class1 = org.codehaus.groovy.trace.Demo.class; Object b = new Integer(10); Object a = new Integer(b.intValue()+new Integer(2).intValue())

and then:

int b' = 10; Object b = new Integer(b'); Object a = new Integer(b'+2);

which of course would be much faster, than what we currently have.But I am not sure there is a way for a JIT we write to get all these informations... like what method will be called in the end.. for 2.0I plan to let the MetaClass return the method it will call instead of calling the method directly. In that a case JIT would have an much more easy job here.

bye blackdrag

-- Jochen "blackdrag" Theodorou The Groovy Project Tech Lead (http://groovy.codehaus.org) http://blackdragsview.blogspot.com/ http://www.g2one.com/

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

http://xircles.codehaus.org/manage_email