Hi,
I need to read millions rows via rust , do some modification and return final result (some stats) to elixir apps via rustler .
When I run rust code with :
cargo run
it takes 40 sec.
cargo run --realease
it takes 1,5 sec.
but when I run it from Elixir via rustler/nif from iex -S mix
it takes 40 sec.
How to run it so fast in similar way like cargo run --release
mode, from elixir apps ?
Thanks for help .
1 Like
Rustler by default uses the MIX_ENV
to determine how to build the nif, if you’re using iex -S mix
the default MIX_ENV
is :dev
, which compiles the nif in debug mode (the 40 seconds use case).
To compile the nif in release mode you can either pass the MIX_ENV
to the iex command MIX_ENV="prod" iex -S mix
or you can pass mode: :release
in the nif config itself, the config options can be found here.
3 Likes
Thanks a lot. Now it works fast