Skip to content

Scala Native 0.3.0

Compare
Choose a tag to compare
@densh densh released this 15 Jun 14:00

New garbage collector 🗑️♻️

(Contributed by @LukasKellenberger in #726)

The main highlight of the release is our new garbage collector called Immix based on [1]. Compared to our current garbage collector the differences and similarities are the following:

  • Tracing garbage collection. Both collectors rely on tracing to perform garbage collection. This means that the collector has no runtime overhead in-between garbage collection cycles unlike some other automatic memory management schemes like reference counting.

  • Precise heap data layout. Immix relies on precise knowledge of the layout of objects on the heap. In comparison, our integration with Boehm is fully conservative.

  • Conservative roots. To keep the compiler interface simple and to avoid requiring newer versions of LLVM with latest GC intrinsics we keep root scanning conservative. Typically this has negligible performance overhead but precludes objects referred from the roots to be moved around.

  • Bump allocation. Unlike most mark-and-sweep implementations, Immix doesn't rely on free lists to allocate memory. Instead, it has a multi-level data structure for the heap that allows for bump allocation across contiguous areas of memory that speeds up allocation considerably.

On all of our throughput benchmarks Immix performs much better than Boehm:

2017-06-01-fast-startup-and-low-latency 001

Here you see running time of our benchmarks (less is better), normalized by the running time with garbage collector turned off. Average GC overhead went down from 100% to 10% with some benchmarks seeing close to 5x improvements.

Immix can enabled in opt-in fashion by adding the following setting in your sbt build:

nativeGC := "immix"

Boehm remains as the default garbage collector until our immix implementation matures.

[1] Stephen M. Blackburn and Kathryn S. McKinley. 2008. Immix: a mark-region garbage collector with space efficiency, fast collection, and mutator performance. In Proceedings of the 29th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI '08). ACM, New York, NY, USA, 22-32.

Sbt test framework integration ☑️

(Contributed by @Duhemm in #755)

We extend our sbt integration to support sbt test frameworks. This means that starting with 0.3, as soon as a testing framework an all of its dependencies are published for the Scala Native platform, one can use them to compile and run Native-compiled test suites.

Sbt cross project feature completeness 🎌

(Contributed by @sjrd in portable-scala/sbt-crossproject#38)

sbt-crossproject is a an sbt plugin that automates cross-compilation and cross-publishing across the three major Scala platforms: JVM, JS and Native. We are happy to announce it's second release: 0.2.0. This release is feature complete with the respect to the original cross projects from Scala.js 0.6.x. New-style cross projects are now used on the master branch of Scala.js (to be released as part of the upcoming 1.0 release.)

Library improvements 📚

#558 Add support for java.net.URI (by @asoltysik)
#694 Add support for a large subset of java.nio.* (by @Duhemm)
#701 Add flush to java.io.FileOutputStream (by @ekrich)
#724 Make java.lang.StackTraceElement closer to Java's impl (by @Duhemm)
#734 Add support for Zone allocation (by @densh)
#743 Add suport for java.util.zip.* (by @Duhemm)
#761 Add support for java.util.ArrayList (by @matil019)
#758 Add bindings for POSIX socket.h (by @Duhemm)
#771 Add bindings for POSIX errno.h (by @rwhaling)

Tooling improvements 🔧

#339 Add support for sbt testing interface (by @Duhemm)
#652 Add new sbt new template (by @MasseGuillaume and @densh)
#686 Implements selector-based row displacement for trait method dispatch, decreasing the size of the generated binaries by up to a factor 5x in some cases (by @densh)
#833 Make sure zlib, re2 and boehm dependencies are truly optional (by @densh)

Bugfixes and perfomance improvements 🐛 👟

#128 New garbage collector: Immix (by @LukasKellenberger and @densh)
#596 System nanotime test sometimes fails (by @muxanick)
#667 Make sure linker doesn't under-approximate in cases of complex trait inheritance (by @densh)
#679 Names in LLVM IR must escape quote character (by @muxanick)
#695 Fix handling of this in loops generated by tailrec (by @densh)
#760 java.io.FileDescriptor.valid should check that file descriptors are actually valid (by @Duhemm)
#762 Compiler tries to box short into int (by @densh)
#765 java.io.FileInputStream constructor should throw java.io.FileNotFoundException on invalid file names (by @mccartney)
#770 FileWriter ignores -1 result from open (by @mccartney)
#794 Signature of java.util.Arrays.asList is wrong (by @hwielenberg)
#799 Up to 15x faster java.io.BufferedReader.readLine (by @densh)
#803 String concat must always convert null arguments to "null" string (by @densh)
#809 Scala hash code must return 0 on null values (by @densh)
#819 Fix the resource leak of java.io.InputStreamReader.close (by @matil019)
#820 java.io.FileInputStream.available should throw java.io.IOException after closed (by @matil019)
#822 Fix the resource leak of java.io.BufferedReader.close (by @matil019)

Contributors 👥

According to git shortlog -sn --no-merges v0.2.1..v0.3.0, 14 people contributed to this release: Denys Shabalin, Martin Duhem, Jonas Fonseca, matil019, Lukas Kellenberger, Eric K Richardson, Mike Samsonov, Greg Oledzki, Shunsuke Otani, Andrzej Sołtysik, Tim Nieradzik, Henning Wielenberg, Richard Whaling, Guillaume Massé.

Thank you all! ✨ 🍰 ✨