This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Google's Scala benchmarks...

5 replies
Marc Edwards
Joined: 2011-06-09,
User offline. Last seen 42 years 45 weeks ago.

My apologies as a first time poster, particularly if this topic has
already been discussed.

http://www.readwriteweb.com/hack/2011/06/cpp-go-java-scala-performance-b...

Considering that Scala is compiled to the JVM byte codes, a colleague
and I are debating the reasons for Scala's higher performance over
Java.

Would a Scala guru venture a quick analysis of this discrepancy?

BTW...I also found this to be an interesting Scala performance
link...http://brizzled.clapper.org/id/88/

Regards, Marc

Randall R Schulz
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
Re: Google's Scala benchmarks...

On Thursday June 9 2011, Marc Edwards wrote:
> My apologies as a first time poster, particularly if this topic has
> already been discussed.
>
> http://www.readwriteweb.com/hack/2011/06/cpp-go-java-scala-performanc
>e-benchmark.php
>
> Considering that Scala is compiled to the JVM byte codes, a colleague
> and I are debating the reasons for Scala's higher performance over
> Java.
>
> Would a Scala guru venture a quick analysis of this discrepancy?
>
> BTW...I also found this to be an interesting Scala performance
> link...http://brizzled.clapper.org/id/88/
>
> Regards, Marc

I think we'd all like to see what explains those numbers!

Randall Schulz

ichoran
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.
Re: Google's Scala benchmarks...
This not infrequently happens to me because I can see the logic of what is happening better in Scala.  If I *actually* create identical code in Java, it is always at least as fast.  But my Java code is more likely to have a bug, and there are certain time-saving constructs that I almost never bother re-implementing (such as views for collections).  In this case, if you read the paper, it turns out that the Java code creates more objects (for reasons that are not entirely obvious to me).  Usually I have that problem in Scala instead, but it's entirely possible to do it in Java also.

  --Rex

On Thu, Jun 9, 2011 at 10:21 AM, Marc Edwards <jmarcedwards [at] gmail [dot] com> wrote:
My apologies as a first time poster, particularly if this topic has
already been discussed.

http://www.readwriteweb.com/hack/2011/06/cpp-go-java-scala-performance-benchmark.php

Considering that Scala is compiled to the JVM byte codes, a colleague
and I are debating the reasons for Scala's higher performance over
Java.

Would a Scala guru venture a quick analysis of this discrepancy?

BTW...I also found this to be an interesting Scala performance
link...http://brizzled.clapper.org/id/88/

Regards, Marc






odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Google's Scala benchmarks...
As far as I know, the unoptimized version had Scala beat Java, because in Scala you can use an Array over parameterized types, whereas in Java you cannot (that's part of the price paid for letting arrays be covariant in Java). So the Java version had to use ArrayLists, which are less efficient. At least that was one of the reasons mentioned why Scala did better.

The optimized versions are too different to be able to pinpoint the gap in performance (at least for me).

Cheers

 -- Martin


On Thu, Jun 9, 2011 at 4:41 PM, Rex Kerr <ichoran [at] gmail [dot] com> wrote:
This not infrequently happens to me because I can see the logic of what is happening better in Scala.  If I *actually* create identical code in Java, it is always at least as fast.  But my Java code is more likely to have a bug, and there are certain time-saving constructs that I almost never bother re-implementing (such as views for collections).  In this case, if you read the paper, it turns out that the Java code creates more objects (for reasons that are not entirely obvious to me).  Usually I have that problem in Scala instead, but it's entirely possible to do it in Java also.

  --Rex

On Thu, Jun 9, 2011 at 10:21 AM, Marc Edwards <jmarcedwards [at] gmail [dot] com> wrote:
My apologies as a first time poster, particularly if this topic has
already been discussed.

http://www.readwriteweb.com/hack/2011/06/cpp-go-java-scala-performance-benchmark.php

Considering that Scala is compiled to the JVM byte codes, a colleague
and I are debating the reasons for Scala's higher performance over
Java.

Would a Scala guru venture a quick analysis of this discrepancy?

BTW...I also found this to be an interesting Scala performance
link...http://brizzled.clapper.org/id/88/

Regards, Marc









--
----------------------------------------------
Martin Odersky
Prof., EPFL and CEO, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967

ichoran
Joined: 2009-08-14,
User offline. Last seen 2 years 3 weeks ago.
Re: Google's Scala benchmarks...
Although what you say is true regarding Array, the benchmarks I've done comparing ArrayList and Array indicated that the gain is modest (not sure about their use case--it gets increasingly bad for ArrayList as the size of the arrays decrease).  Anyway, Scala apparently loses that advantage elsewhere, because on page 8 they say:

    In other words, Scala spends 7699-2416-1 = 5282 clicks on
    non-GC code. Java spends 14073-10484-110-2 = 3477 clicks
    on non-GC code. Since GC has other negative performance
    side-effects, one could estimate that without the GC anomaly,
    Java would be about roughly 30% faster than Scala.

So they seem to have fingered garbage collection for the unoptimized versions.  The ArrayList thing may be part of the reason why Java had a heavier GC load, however.

  --Rex

On Thu, Jun 9, 2011 at 10:50 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
As far as I know, the unoptimized version had Scala beat Java, because in Scala you can use an Array over parameterized types, whereas in Java you cannot (that's part of the price paid for letting arrays be covariant in Java). So the Java version had to use ArrayLists, which are less efficient. At least that was one of the reasons mentioned why Scala did better.

The optimized versions are too different to be able to pinpoint the gap in performance (at least for me).

Cheers

 -- Martin


On Thu, Jun 9, 2011 at 4:41 PM, Rex Kerr <ichoran [at] gmail [dot] com> wrote:
This not infrequently happens to me because I can see the logic of what is happening better in Scala.  If I *actually* create identical code in Java, it is always at least as fast.  But my Java code is more likely to have a bug, and there are certain time-saving constructs that I almost never bother re-implementing (such as views for collections).  In this case, if you read the paper, it turns out that the Java code creates more objects (for reasons that are not entirely obvious to me).  Usually I have that problem in Scala instead, but it's entirely possible to do it in Java also.

  --Rex

On Thu, Jun 9, 2011 at 10:21 AM, Marc Edwards <jmarcedwards [at] gmail [dot] com> wrote:
My apologies as a first time poster, particularly if this topic has
already been discussed.

http://www.readwriteweb.com/hack/2011/06/cpp-go-java-scala-performance-benchmark.php

Considering that Scala is compiled to the JVM byte codes, a colleague
and I are debating the reasons for Scala's higher performance over
Java.

Would a Scala guru venture a quick analysis of this discrepancy?

BTW...I also found this to be an interesting Scala performance
link...http://brizzled.clapper.org/id/88/

Regards, Marc









--
----------------------------------------------
Martin Odersky
Prof., EPFL and CEO, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967


Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: Google's Scala benchmarks...
This is, in fact, a huge result.   There was a lot of internal discussion on this benchmarking.   Part of the goal was to start off with simple code and see the results, then optimise using language expertise.  When optimised, the Java can perform better than Scala, although I think Scala could even catch up here given sufficient attention.
- Josh

On Thu, Jun 9, 2011 at 10:50 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
As far as I know, the unoptimized version had Scala beat Java, because in Scala you can use an Array over parameterized types, whereas in Java you cannot (that's part of the price paid for letting arrays be covariant in Java). So the Java version had to use ArrayLists, which are less efficient. At least that was one of the reasons mentioned why Scala did better.

The optimized versions are too different to be able to pinpoint the gap in performance (at least for me).

Cheers

 -- Martin


On Thu, Jun 9, 2011 at 4:41 PM, Rex Kerr <ichoran [at] gmail [dot] com> wrote:
This not infrequently happens to me because I can see the logic of what is happening better in Scala.  If I *actually* create identical code in Java, it is always at least as fast.  But my Java code is more likely to have a bug, and there are certain time-saving constructs that I almost never bother re-implementing (such as views for collections).  In this case, if you read the paper, it turns out that the Java code creates more objects (for reasons that are not entirely obvious to me).  Usually I have that problem in Scala instead, but it's entirely possible to do it in Java also.

  --Rex

On Thu, Jun 9, 2011 at 10:21 AM, Marc Edwards <jmarcedwards [at] gmail [dot] com> wrote:
My apologies as a first time poster, particularly if this topic has
already been discussed.

http://www.readwriteweb.com/hack/2011/06/cpp-go-java-scala-performance-benchmark.php

Considering that Scala is compiled to the JVM byte codes, a colleague
and I are debating the reasons for Scala's higher performance over
Java.

Would a Scala guru venture a quick analysis of this discrepancy?

BTW...I also found this to be an interesting Scala performance
link...http://brizzled.clapper.org/id/88/

Regards, Marc









--
----------------------------------------------
Martin Odersky
Prof., EPFL and CEO, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967


Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland