What is doing -optimize

131 views
Skip to first unread message

Francois

unread,
May 4, 2011, 10:08:05 AM5/4/11
to scala-user
Hello,

I'm wondering what is doing the "-optimize" option of the compiler ? I mean, the name is rather explicit, but what kind of optimization are actually done ? Are they relevant ? And if so, why "-optimize" is not the default ? Is it not mature enough, or could it lead to bugs, changed semantic, etc ?

Thanks a lot,
-- 
Francois ARMAND
http://fanf42.blogspot.com
http://www.normation.com

Dennis Haupt

unread,
May 4, 2011, 10:24:26 AM5/4/11
to Francois, scala...@googlegroups.com
it's slower. since scalac is already, let's say, not the fastest horse in town, you might want to save some time for non-release-builds

-------- Original-Nachricht --------
> Datum: Wed, 04 May 2011 16:08:05 +0200
> Von: Francois <fan...@gmail.com>
> An: scala-user <scala...@googlegroups.com>
> Betreff: [scala-user] What is doing -optimize

Francois

unread,
May 4, 2011, 11:59:27 AM5/4/11
to scala...@googlegroups.com
On 04/05/2011 16:24, Dennis Haupt wrote:
> it's slower. since scalac is already, let's say, not the fastest horse in town, you might want to save some time for non-release-builds
>

Thanks, I should have guess that. But does the time overhead worth it ?
Or more precisely, in which kind of applications or code does it matter ?

HamsterofDeath

unread,
May 4, 2011, 12:26:43 PM5/4/11
to scala...@googlegroups.com
no idea, but i guess it's worth it

Rex Kerr

unread,
May 4, 2011, 2:08:55 PM5/4/11
to Francois, scala...@googlegroups.com
I have never found a case where production code was significantly sped up by using -optimise, at least when using the Sun JVM.  I grant that in some cases it could happen, but it seems to apply similar optimizations to what the JVM does already.  Perhaps if there are limits on optimization depth, using -optimise would remove a few layers and then allow the JVM to get a few more.  But I mostly don't even bother testing it any more, given how many cases (dozens) I've tried it where the runtime hasn't changed measurably.

I expect it would have an impact on VMs that are more conservative (e.g. JRockit) or less sophisticated (e.g. Dalvik).

  --Rex

Ismael Juma

unread,
May 10, 2011, 12:28:09 PM5/10/11
to Francois, scala-user
On Wed, May 4, 2011 at 3:08 PM, Francois <fan...@gmail.com> wrote:
> I'm wondering what is doing the "-optimize" option of the compiler ? I mean,
> the name is rather explicit, but what kind of optimization are actually done
> ? Are they relevant ? And if so, why "-optimize" is not the default ?

The scala distribution is actually compiled with -optimise, but indeed
it's not on unless the argument is passed to scalac.

> Is it not mature enough, or could it lead to bugs, changed semantic, etc ?

As far as I understand, the team decided to be conservative and enable
it only for the scala distribution as an initial step (in Scala
2.8.0). Maybe it's a good idea to consider extending that in the next
major release.

Best,
Ismael

Reply all
Reply to author
Forward
0 new messages