Skip to content

@densh densh released this May 24, 2019 · 11 commits to master since this release

This release is a first public preview of the features an changes coming 0.4.0 final. Some of the major highlights are listed below, for a full list of changes please see the following page.

Performance improvements 👟

(by @densh and @valdisxp1)

As announced earlier, Scala Native 0.4.0 is going to feature a brand new whole-program optimizer called Interflow. See the original announcement for additional technical details on how it works under the hood.

Additionally, we also have a number of GC performance improvements that made major impact on allocator performance of our Immix garbage collector and also reduce the overhead of the GC metadata. To get best performance one has to use a new flag for enabling LTO across C/Scala boundary nativeLTO := "thin". See the sbt plugin docs for more details.

The combination of these two changes gives us following speedups on our benchmarks:

SN03

JDK11

Library improvements and bugfixes 📚 🐛

  • New regex implementation (by @LeeTibbert, @techaddict, @MasseGuillaume, @densh)

    Previously we used to have a dependency on C-based RE2 implementation for regular expressions. In 0.4.0 we've ported the regex engine to Scala to remove that dependency. This would also allow us to narrow the gap between JDK and Scala Native regex treatment over time.

  • Bundle libunwind with Scala Native (by @shadaj)

    Thanks to this change and new regex engine, we don't have any more 3-rd party library dependencies in the core. See latest setup instructions for the simplified environment setup instructions.

  • New toString implementation (by @LeeTibbert)

    Scala Native now uses a port of ulfjack/ryu for floating point to string conversions. This has major performance improvements on benchmarks that rely on this functionality on the hot path as described in the original paper. Additionally make string formatting of Float and Double much more inline with formatting of the reference on the JVM.

  • Countless other changes to improve library compatibility and fix bugs. See the link in the beginning for the complete list of changes.

Interoperability changes 🎌

(by @densh)

0.4.0 is going to feature a revised interoperability layer. Some of the key changes:

  • The previous scalanative.native namespace has been split into scalanative.unsafe, scalanative.annotation, scalanative.unsigned and scalanative.libc.
  • All of the interop types such as Ptr, CStructN and CArray are now well-behaved with respect to boxing. This allows those types to be used as elements of Scala collections for example.
  • All of the interop types are now well-behaved with respect to generics via unsafe.Tag (similar to reflect.ClassTag). This allows one to abstract over elements of Ptr and CArray types and perform operations on those elements generically.
  • Function pointers have a new SAM-based encoding via CFuncPtrN. Unlike previous design new function pointers are aimed primarily at providing callbacks to Scala back from C. They are not compiled as raw C-style function pointer but rather a managed object that gets turned into function pointer on the C boundary.
  • Varargs are now compiled to va_list instead of C's .... Support for ... has been dropped. This fixes a number of issues with older vararg implementation making varargs behave well when used together with boxing or generics.
  • _N accessors don't require additional dereference when used for accessing struct fields. If you used to rely on previous behavior to get a pointer at the field element, use atN instead.

Tooling and build improvements 🔧

(by @densh and @LeeTibbert)

  • release mode has been split into release-fast (faster to compile, less optimizations, best binary size) and release-full (slower to compile, all optimizations, worst binary size). release mode now aliases to release-full.
  • new nativeLTO, nativeCheck and nativeDump sbt settings. See the docs for details.
  • improved linking error diagnostics by showing a stack traces that lead to a missing symbol.
  • numerous compilation performance and toolchain scalability improvements.
  • resolved a long standing bug (#375) in linking across the JDK boundary via new rewritten reachability analysis.
  • resolved a long standing bug (#1008) in unit testing layer that used to caused crashes when running with large number of unit tests suites.
  • automatically discover clang 7 and 8 by default.

License change 📜

Similarly to the Scala project itself, Scala Native is now licensed under Apache License 2.0.

Contributors 👥

According to git shortlog -sn --no-merges v0.3.8..v0.4.0-M2, 15 people contributed over 170 pull requests to this release: Denys Shabalin, LeeTibbert, Eric K Richardson, Valdis Adamsons, Darcy Shen, Shadaj Laddad, Nadav Samet, Naohisa Murakami, Paweł Cejrowski, Jorge, Dubray Alexandre, Jimin Hsieh, Jonas Fonseca, Andrew Smith, Lorenzo Gabriele.

Thank you all! 🍰

Assets 2
You can’t perform that action at this time.