gpt4 book ai didi

performance - 'optimise' scala 编译器标志有什么作用?

转载 作者:行者123 更新时间:2023-12-03 11:02:14 24 4
gpt4 key购买 nike

我试过使用 scalac -optimise版本 2.7.7。当时我从未得到任何性能改进,但编译时间更长。

Scala 2.9.0 的情况是否更好?该标志目前涵盖哪些优化?

最佳答案

奇怪,居然还有similar question on the scala-user group :

Rex Kerr当时的回答(五月):

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).



Ismael Juma添加:

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 ?



据我了解,团队决定保守并启用
它仅用于 Scala 分布作为初始步骤(在 Scala 中
2.8.0)。也许考虑在下一个扩展它是个好主意
主要发布。


对于' -optimise的影响'(以及其他因素)在 Scala2.9 中,请参阅此 scala-language thread called "Scala2.9 slower?" .

I'm a bit concerned. After seeing that -optimize really does optimize "for comprehensions" on 2.9.0, I then benchmarked the code, and discovered it was about 2.5 times slower than 2.8.1.



结果留下了……复杂的感觉。

关于performance - 'optimise' scala 编译器标志有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6704233/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com