JIT in Erlang – what does it mean for Elixir?

JIT is coming to Erlang. Will that then also benefit Elixir apps?

If I understand correctly, JIT allows to improve performance of the application; i.e. execution time?

How do we use JIT in Elixir?

I think you don’t do anything (maybe turn on a vm flag) and it just does its thing. Sit back and enjoy a performance gain. The blog article says Jason gets a big speed bump.

8 Likes

With CLDR release 39 out next month I am on my usual bi-annual compatibility and maintenance cycle for the ex_cldr libraries and decided to see if some critical code will benefit from the JIT compiler in OTP 24.

This simple example is formatting a number which is a complex operation given the flexibility of the formatting system. Overall the performance is about twice as fast for this function which is a big win.

With the JIT (OTP 24.0-rc0)

Name                                            ips        average  deviation         median         99th %
:erlang.float_to_binary                   7663.86 K       0.130 μs  ±2026.91%           0 μs           1 μs
Float to_string                            976.30 K        1.02 μs  ±7209.48%           1 μs           2 μs
Number to_string preformatted options      183.40 K        5.45 μs   ±416.76%           4 μs          15 μs
Number to_string                            56.33 K       17.75 μs   ±348.13%          15 μs          65 μs

Without the JIT (OTP 23.2.2)

Name                                            ips        average  deviation         median         99th %
:erlang.float_to_binary                   6213.10 K       0.161 μs  ±1823.26%           0 μs           1 μs
Float to_string                            533.39 K        1.87 μs  ±2067.68%           2 μs           2 μs
Number to_string preformatted options       89.48 K       11.18 μs   ±166.50%          10 μs          22 μs
Number to_string                            23.98 K       41.70 μs    ±64.88%          40 μs          69 μs
19 Likes