Odersky Martin |
Scala Native is an optimizing ahead-of-time compiler and lightweight managed runtime designed specifically for Scala.
It offers the following features:
Scala Native relies on LLVM as its primary optimizer as of the latest 0.3.7 release. Although LLVM fits this role quite well, we have found that LLVM intermediate representation is sometimes too low-level for the Scala programming language. To address this challenge, we developed Interflow, a flow-sensitive, profile-guided optimizer for Scala Native. It operates on the Scala Native’s intermediate representation called NIR. Unlike LLVM IR, it preserves full information about object-oriented features.
In our experiments using the current prototype of Interflow on Scala Native benchmarks on a machine equipped with Intel i9 7900X CPU, we demonstrated that Interflow achieves up to 3.09x higher throughput (with a geometric mean speedup of 1.8x) than Scala Native 0.3.7. Moreover, with the addition of PGO, Interflow gets up to 4.71x faster (with a geometric mean speedup 1.96x) faster than the Scala Native.
In the future, we plan to provide support for profile-guided optimization as an opt-in feature for users who want to obtain absolute best peak performance for Scala Native compiled code.
Suggested Reading:
https://scala-native.readthedocs.io/en/v0.3.9-docs/
https://scala-native.readthedocs.io/en/v0.3.9-docs/blog/interflow.html
https://github.com/densh/talks/blob/master/2018-06-16-interflow-preprint-v1.pdf