Chanwit Kaewkasi | 15 Aug 02:04
Gravatar

[groovy-dev] Groovy JIT and Partial Sums Benchmark

Hello all,

I've been writing a JIT for Groovy in my GSOC period, and I've got the
alpha code quality with some figures to show.
When a JIT technique, you don't need to worry about MOP representation
in bytecode as long as the default metaclass is not changed.
I use JVMTI to make this happen (I'm lucky enough to find the way to
avoid Java 6 specific feature and able to implement it for Java 5).

I'm confident that we are now able to get Java-near speed for Groovy :-)

Before going to the figures, I'd like to thank you:
  - Guillaume to let me in GSOC program this year,
  - Alex T. for making callsite fast enough to make me to find an
alternative way - and look back to my GJIT project,
  - Jochen for his questions and thoughts of how to remove
"box/unbox"-ing pairs.

This partial sums benchmark is from shootout. I've selected it to be
the first one because the ease of implementation.
As I mentioned, the JIT quality is still alpha, but at least I've got
a good enough code structure to patch (and patch).
My current goal is to beat all shootout benchmarks at the moment, and
I hope to finally have some more figures to show.

- PartialSumsJ is Java implementation of partial sums, taken from shootout.
- partial_sums.groovy is untyped version, taken from shootout.
- alioth/PartialSums.groovy is typed version, modified from partial_sums.groovy
All results use Java 1.6_06 with -server option.

(Continue reading)

Favicon

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Chanwit Kaewkasi wrote:
> $ export JAVA_OPTS="-server"
> $ time `java -cp bin alioth.PartialSumsJ 5000000`
> real    0m10.246s
> user    0m0.030s
> sys     0m0.015s

It doesn't appear you ran the Java benchmark with the server VM here. 
JAVA_OPTS is not observed by the Java command.

- Charlie

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

    http://xircles.codehaus.org/manage_email

Chanwit Kaewkasi | 15 Aug 07:19
Gravatar

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Hello Charles,

It's my fault. Thank your for spotting this error.
Here's the new result:

$ time `java -server -cp bin alioth.java.PartialSums 5000000`

real    0m9.378s
user    0m0.030s
sys     0m0.015s

Regards,

Chanwit

p.s. class name is different because of recently refactoring.

2008/8/15 Charles Oliver Nutter <charles.nutter@...>:
> Chanwit Kaewkasi wrote:
>>
>> $ export JAVA_OPTS="-server"
>> $ time `java -cp bin alioth.PartialSumsJ 5000000`
>> real    0m10.246s
>> user    0m0.030s
>> sys     0m0.015s
>
> It doesn't appear you ran the Java benchmark with the server VM here.
> JAVA_OPTS is not observed by the Java command.
>
> - Charlie
(Continue reading)

Tom Nichols | 15 Aug 14:16

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

That means the -server option wasn't used for the Groovy benchmarks
either, right?  Or does Groovy use -server automatically?

On Fri, Aug 15, 2008 at 1:19 AM, Chanwit Kaewkasi <chanwit@...> wrote:
> Hello Charles,
>
> It's my fault. Thank your for spotting this error.
> Here's the new result:
>
> $ time `java -server -cp bin alioth.java.PartialSums 5000000`
>
> real    0m9.378s
> user    0m0.030s
> sys     0m0.015s
>
> Regards,
>
> Chanwit
>
> p.s. class name is different because of recently refactoring.
>
> 2008/8/15 Charles Oliver Nutter <charles.nutter@...>:
>> Chanwit Kaewkasi wrote:
>>>
>>> $ export JAVA_OPTS="-server"
>>> $ time `java -cp bin alioth.PartialSumsJ 5000000`
>>> real    0m10.246s
>>> user    0m0.030s
>>> sys     0m0.015s
>>
(Continue reading)

Martin C. Martin | 15 Aug 14:22

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Groovy listens to the JAVA_OPTS env var.

It might be clearer if, instead of export, you set it on the same 
command line, i.e.:

JAVA_OPTS=-server time groovy ....

That way, you can be sure the option is set for benchmark.

BTW, you don't need the back ticks, although I don't think they hurt.

Best,
Martin

Tom Nichols wrote:
> That means the -server option wasn't used for the Groovy benchmarks
> either, right?  Or does Groovy use -server automatically?
> 
> On Fri, Aug 15, 2008 at 1:19 AM, Chanwit Kaewkasi <chanwit@...> wrote:
>> Hello Charles,
>>
>> It's my fault. Thank your for spotting this error.
>> Here's the new result:
>>
>> $ time `java -server -cp bin alioth.java.PartialSums 5000000`
>>
>> real    0m9.378s
>> user    0m0.030s
>> sys     0m0.015s
>>
(Continue reading)

Daniel.Sun | 15 Aug 14:29
Favicon

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark


Hi Chanwit,

I'm very glad to see the progress of GJIT.

I have noticed GJIT since it was invented.

Now I wonder whether or not GJIT will be integrated into Groovy when GJIT is
mature enough.

Maybe Guillaume, Jochen, Alex, Paul or someone else can answer me the
question :)

Cheers,
Daniel.Sun

chanwit wrote:
> 
> Hello all,
> 
> I've been writing a JIT for Groovy in my GSOC period, and I've got the
> alpha code quality with some figures to show.
> When a JIT technique, you don't need to worry about MOP representation
> in bytecode as long as the default metaclass is not changed.
> I use JVMTI to make this happen (I'm lucky enough to find the way to
> avoid Java 6 specific feature and able to implement it for Java 5).
> 
> I'm confident that we are now able to get Java-near speed for Groovy :-)
> 
> Before going to the figures, I'd like to thank you:
(Continue reading)

Martin C. Martin | 15 Aug 14:36

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

I agree, this is great progress!

Previously, the Groovy team has been against any changes for efficiency 
if they reduce the dynamic nature of Groovy at all.  Does GJIT change 
the behavior of Groovy code that uses non-default metaclasses?  If so, 
how should GJIT be handled?

Best,
Martin

Daniel.Sun wrote:
> Hi Chanwit,
> 
> I'm very glad to see the progress of GJIT.
> 
> I have noticed GJIT since it was invented.
> 
> Now I wonder whether or not GJIT will be integrated into Groovy when GJIT is
> mature enough.
> 
> Maybe Guillaume, Jochen, Alex, Paul or someone else can answer me the
> question :)
> 
> Cheers,
> Daniel.Sun
> 
> 
> chanwit wrote:
>> Hello all,
>>
(Continue reading)

Chanwit Kaewkasi | 15 Aug 14:47
Gravatar

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

2008/8/15 Martin C. Martin <martin@...>:
> I agree, this is great progress!
>
> Previously, the Groovy team has been against any changes for efficiency if
> they reduce the dynamic nature of Groovy at all.  Does GJIT change the
> behavior of Groovy code that uses non-default metaclasses?  If so, how
> should GJIT be handled?
>
> Best,
> Martin

Hello Martin,

No. There will be a hook into metaclass to detect such changes. If you
install a new metaclass, GJIT will revert the class's bytecode to the
orignal one.

>
> Daniel.Sun wrote:
>>
>> Hi Chanwit,
>>
>> I'm very glad to see the progress of GJIT.
>>
>> I have noticed GJIT since it was invented.

Thanks Daniel :-)

>> Now I wonder whether or not GJIT will be integrated into Groovy when GJIT
>> is
(Continue reading)

Alex Tkachman | 15 Aug 16:20

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

I am very interested to have a look on code and learn more about ideas
and general principals before have any judgments about that. But if it
is really so good we should consider to include it in some future
version on Groovy (1.7 maybe)

On Fri, Aug 15, 2008 at 4:29 PM, Daniel.Sun <realbluesun@...> wrote:
>
> Hi Chanwit,
>
> I'm very glad to see the progress of GJIT.
>
> I have noticed GJIT since it was invented.
>
> Now I wonder whether or not GJIT will be integrated into Groovy when GJIT is
> mature enough.
>
> Maybe Guillaume, Jochen, Alex, Paul or someone else can answer me the
> question :)
>
> Cheers,
> Daniel.Sun
>
>
> chanwit wrote:
>>
>> Hello all,
>>
>> I've been writing a JIT for Groovy in my GSOC period, and I've got the
>> alpha code quality with some figures to show.
>> When a JIT technique, you don't need to worry about MOP representation
(Continue reading)

Favicon

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

I'm also interested in the techniques involved, since JRuby already  
has deferred compilation and an interpreted mode, so it would be very  
easy to do the same. Up to now Ive only incorporated static  
optimizations, but have already started looking at dynamic  
optimizations based on profile data gathered during interpretation.  
The primary limiting factor is determining which opts can be done  
safely, providing reliable guards that don't severely impact normal  
execution, and dealing with the costs of repeatedly compiling and  
loading bytecode. I think this last area is the most problematic,  
since in JRuby we've actually had to throttle compilation in some  
cases, and we've also seen that deferred compilation can confuse  
HotSpot to the point of causing permanent deoptimization.

- Charlie

On Aug 15, 2008, at 10:20, Alex Tkachman <alex.tkachman@...>  
wrote:

> I am very interested to have a look on code and learn more about ideas
> and general principals before have any judgments about that. But if it
> is really so good we should consider to include it in some future
> version on Groovy (1.7 maybe)
>
> On Fri, Aug 15, 2008 at 4:29 PM, Daniel.Sun  
> <realbluesun@...> wrote:
>>
>> Hi Chanwit,
>>
>> I'm very glad to see the progress of GJIT.
>>
(Continue reading)

Chanwit Kaewkasi | 16 Aug 23:51
Gravatar

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Hello Charles,

My idea is far simple than you think, because I have not tackled other
kind of callsites in general yet. As you've known, I'm focusing only
on primitive operations now.

I'm not sure that you're interested to use JVMTI for re-defining
classes or not. But in case of Groovy, I think it's necessary because
Groovy has no interpreter.

My current concern to dealing with dynamic dispatch now is just to
determine the return type of cached callsites, and if they are
primitive, the binary operation that take them as operands will be
primitive bytecodes instead of MOP (as far as the default metaclass is
still there). And if the metaclass is changed, everything is reverted
back.

However, my experiences in dynamic languages is not much (compared
with most people in this list). My approach is probably not working
well (or at all) in some situation, but I hope it will be a good start
for me to tackling Groovy performance issues.

Regards,

Chanwit

2008/8/15 Charles Oliver Nutter <charles.nutter@...>:
> I'm also interested in the techniques involved, since JRuby already has
> deferred compilation and an interpreted mode, so it would be very easy to do
> the same. Up to now Ive only incorporated static optimizations, but have
(Continue reading)

Jochen Theodorou | 15 Aug 16:23
Gravatar

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Daniel.Sun schrieb:
> Hi Chanwit,
> 
> I'm very glad to see the progress of GJIT.
> 
> I have noticed GJIT since it was invented.
> 
> Now I wonder whether or not GJIT will be integrated into Groovy when GJIT is
> mature enough.
> 
> Maybe Guillaume, Jochen, Alex, Paul or someone else can answer me the
> question :)

if the outcome proves to be good, then we should integrate it as 
something the user can enable...

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

(Continue reading)

Chanwit Kaewkasi | 15 Aug 16:49
Gravatar

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Thanks Alex and Jochen,

I'm looking forward to hearing more about your feedbacks, especially
for technical things.

Regards,

Chanwit

2008/8/15 Alex Tkachman <alex.tkachman@...>:
> I am very interested to have a look on code and learn more about ideas
> and general principals before have any judgments about that. But if it
> is really so good we should consider to include it in some future
> version on Groovy (1.7 maybe)

2008/8/15 Jochen Theodorou <blackdrag@...>:
> Daniel.Sun schrieb:
>
> if the outcome proves to be good, then we should integrate it as something
> the user can enable...

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

    http://xircles.codehaus.org/manage_email

Guillaume Laforge | 15 Aug 21:13
Gravatar

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Very promising, Chanwit, congratulations!

On Fri, Aug 15, 2008 at 2:05 AM, Chanwit Kaewkasi <chanwit@...> wrote:
> Hello all,
>
> I've been writing a JIT for Groovy in my GSOC period, and I've got the
> alpha code quality with some figures to show.
> When a JIT technique, you don't need to worry about MOP representation
> in bytecode as long as the default metaclass is not changed.
> I use JVMTI to make this happen (I'm lucky enough to find the way to
> avoid Java 6 specific feature and able to implement it for Java 5).
>
> I'm confident that we are now able to get Java-near speed for Groovy :-)
>
> Before going to the figures, I'd like to thank you:
>  - Guillaume to let me in GSOC program this year,
>  - Alex T. for making callsite fast enough to make me to find an
> alternative way - and look back to my GJIT project,
>  - Jochen for his questions and thoughts of how to remove
> "box/unbox"-ing pairs.
>
> This partial sums benchmark is from shootout. I've selected it to be
> the first one because the ease of implementation.
> As I mentioned, the JIT quality is still alpha, but at least I've got
> a good enough code structure to patch (and patch).
> My current goal is to beat all shootout benchmarks at the moment, and
> I hope to finally have some more figures to show.
>
> - PartialSumsJ is Java implementation of partial sums, taken from shootout.
> - partial_sums.groovy is untyped version, taken from shootout.
(Continue reading)

Chanwit Kaewkasi | 16 Aug 23:51
Gravatar

Re: [groovy-dev] Groovy JIT and Partial Sums Benchmark

Thank you, Guillaume.

Regards,

Chanwit

2008/8/16 Guillaume Laforge <glaforge@...>:
> Very promising, Chanwit, congratulations!
>
> On Fri, Aug 15, 2008 at 2:05 AM, Chanwit Kaewkasi <chanwit@...> wrote:
>> Hello all,

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

    http://xircles.codehaus.org/manage_email


Gmane