jlouis / enacl

Erlang bindings for NaCl / libsodium
MIT License
197 stars 59 forks source link

Erlang dirty schedulers are not actually being used in many cases (if not in all the cases) #71

Open timofey-barmin opened 8 months ago

timofey-barmin commented 8 months ago

The following macro in enacl_nif.c determines if dirty schedulers are to be used or not:

#ifdef ERL_NIF_DIRTY_JOB_CPU_BOUND
#define erl_nif_dirty_job_cpu_bound_macro(a, b, c)                             \
  { a, b, c, ERL_NIF_DIRTY_JOB_CPU_BOUND }
#else
#define erl_nif_dirty_job_cpu_bound_macro(a, b, c)                             \
  { a, b, c }
#endif

The problem with that code is that ERL_NIF_DIRTY_JOB_CPU_BOUND is not actually defined. ERL_NIF_DIRTY_JOB_CPU_BOUND has always been a enum, so "ifdef" can't be used for checking it. This leads to the fact that the #else branch works all the time, and dirty schedulers are not actually being used for functions like pwhash where it is absolutely necessary.

Please consider the following PR to fix that problem: https://github.com/jlouis/enacl/pull/70