Scala Native v0.4.0 Release Notes

Release Date: 2019-05-24 // about 5 years ago
  • ๐Ÿš€ 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:



    ๐Ÿ›  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.
    • 0๏ธโƒฃ 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! โœจ ๐Ÿฐ โœจ

Previous changes from v0.3.9

  • ๐Ÿš€ This release has been championed by @ekrich to enable ekrich/sconfig and scalameta/scalafmt cross-compiling to Scala Native 0.3.x. Special thanks to him for this effort! ๐Ÿ‘

    ๐Ÿฑ Library improvements ๐Ÿ“š

    ๐Ÿ‘ #1419 Add forwarders to support sconfig and scalafmt (by @ekrich)
    ๐Ÿšš #1429 Move UnicodeBlock and Subset under Character object (by @thesamet)
    #1452 Add java.util.IdentityHashMap (by @ekrich)
    โœจ #1488 Enhance to support URI (by @ekrich)
    #1489 Add minimal java.time.Duration (by @ekrich)
    #1490 Add unimplemented method to java.util.Properties (by @ekrich)
    #1492 Add stubs to URL and URLConnection (by @ekrich)
    #1514 Add a few more forwarders to scalafmt to link (by @densh)

    ๐Ÿ›  Bugfixes ๐Ÿ›

    ๐Ÿ‘ #1486 Support assignment to extern variables (by @jonas)

    Contributors ๐Ÿ‘ฅ

    ๐Ÿš€ According to git shortlog -sn --no-merges v0.3.8..v0.3.9, 4 people contributed to this release: Eric K Richardson, Denys Shabalin, Jonas Fonseca, Nadav Samet.

    ๐Ÿฑ Thank you all! โœจ ๐Ÿฐ โœจ