In the release notes for 25 RCs there is the little nugget * The JIT now does type-based optimizations based on type information in the BEAM files.
Unfortunately there is no real expansion on this in the notes, and I have not been able to find the usual blog post we see for major features.
I’m interested to understand:
a) what optimizations are happening
b) will we be able to use type-hinting (maybe even just info from -specs) to force the compiler to apply said optimizations (regardless of correctness)
c) will this eventually get Erlang “performance” closer to other languages
We will probably write one or more blog posts around the time of the release.
In general, the JIT will remove type tests that are not needed. It might also be able to remove code for error handling if it can know that the operation will never fail. For example, if we have the expression A + B and the compiler has determined that A and B are both small integers and that the result will also be a small integer, the JIT will not emit any type tests or any overflow test or any fallback code for addition of big integers.
The optimizations in OTP 25 are just the beginning. We hope to extend both the type information that the compiler can figure out and the optimizations that the JIT can perform in future releases.
No. Only safe type information will be emitted by the compiler and the JIT will only apply safe optimizations.
Thank you for the reply and for the continued improvements to Erlang
Side note for anyone who’s interested. I was going down the rabbit hole and having a look at Cinder which also uses asmjit and see they’re using type hinting in StaticPython to achieve some impressive results.