4 ms·
Did this just make numerical computations, something Erlang is known to be very slow at, 4x faster?
by alberth 4y ago
Did this just make numerical computations, something Erlang is known to be very slow at, 4x faster?
- macintux 4y agoI have no idea, but I suppose when every integer is effectively a bignum, there’s plenty of room for optimization.
- di4na 4y agoFunnily enough... It is really hard if not impossible to optimise when everything is bignum.
- titzer 4y agoWhile JavaScript didn't have BigInt until a couple years ago, it did start with all numbers being floats. JSVMs optimize heavily for the small integer (SMI) case. They do both dynamic profiling, speculative optimization, and significant type analysis to get very good code for the SMI cases.
- di4na 4y agoyou realise floats are far easier because in any case you are limited to 64 bits and you know that?
- Joker_vD 4y agoYeah, just look at Scheme or any other Lisp!
- wahern 4y agoIt looks more like the JIT improvements made it profitable to manually unroll some loops in the base64 module: https://github.com/erlang/otp/commit/a03cf1601605dee767cd9d5f18fc44fc39148795 https://github.com/erlang/otp/commit/a03cf1601605dee767cd9d5... IOW, the 4x improvement seems to largely come from a refactor of the base64 module, not from compiler improvements per se.
- di4na 4y agoNo. What makes it "slow" is fundamentally that 1. Everything is bignum. 2. That any operation can be yielded. It makes it really hard to optimise things that could be sped up by fusing operations.
- gregors 4y agoolder conversation about multiplying benchmarks. I saw a huge improvement when the JIT was introduced. Can't wait to see further improvements https://news.ycombinator.com/item?id=26707354 https://news.ycombinator.com/item?id=26707354
- hinkley 4y agoIBM's early versions of the J9 compiler had a clever way of yielding (I assume you mean green thread yielding and not generator/closure yielding?) Basically the thread scheduling system could trigger an overflow/underflow exception via a fairly fast operation by pushing an illegal value into a watchdog for the thread. An instruction was injected at the top of each function, loop, where the condition of the registers was in a knowable state, and I think a few other places to guarantee a degree of fairness. For more realtime behavior you'd need to pepper these calls in many places, and any fusion operations would need to inject something similar into the instruction stream. Then you'd have to be very, very careful to avoid cache line aliasing that would crash the throughput via false sharing.
- PhilipRoman 4y agoI wish x86 had an easy way to accumulate overflow flags, you could compile entire basic blocks as if they were using native integers, do a single check at the end, and if needed, roll back the computation. The yielding part is harder. You need to have infrastructure in place to dynamically flush certain operations when unexpected yields happen.
- moonchild 4y agoFloats can do it. Do your computation, and then check the inexact flag.