nickva commented on PR #4814: URL: https://github.com/apache/couchdb/pull/4814#issuecomment-1773108294
> I'd considered https://github.com/esl/fast_pbkdf2/ before I noticed they'd made it part of crypto.erl. It just hadn't occurred to me that it would be worse. I will switch to fast_pbkdf2 instead, which does the NIF yieldy goop we need. Or even upgrading our pbkdf2 could work too but yeah that one does seem to do better. Here is an escript which shows the abnormal behavior: ```erlang #!/usr/bin/env escript %% -*- erlang -*- -mode(compile). hash() -> crypto:pbkdf2_hmac(sha256, <<"password">>, <<"salt">>, 1500000, 32), %timer:sleep(1), %erlang:yield(), hash(). spawn_hasher() -> spawn_link(fun() -> timer:sleep(round(rand:uniform() * 10)), hash() end). main([TimeSecStr, HashersStr]) -> TimeSec = list_to_integer(TimeSecStr), Hashers = list_to_integer(HashersStr), HasherPids = [spawn_hasher() || _ <- lists:seq(1, Hashers)], io:format(" * ~p hashers started, measuring scheduler usage for ~p seconds~n", [Hashers, TimeSec]), T0 = erlang:monotonic_time(millisecond), msacc:start(TimeSec * 1000), T1 = erlang:monotonic_time(millisecond), io:format(" * killing ~p hashers~n", [Hashers]), [begin unlink(Pid), exit(Pid, kill) end || Pid <- HasherPids], io:format(" * displaying msacc stats~n", []), msacc:print(msacc:stats(), #{system => true}), io:format(" * time it took to run: ~p~n", [(T1-T0)/1000]), io:format(" * done~n"). ``` It should be done in about 10 second but it just block and until I stopped it by hand: ``` % time ./pbkdfprocs.escript 10 4 * 4 hashers started, measuring scheduler usage for 10 seconds ^C ./pbkdfprocs.escript 10 4 51.52s user 0.38s system 99% cpu 52.347 total ``` I'll make an OTP issue, otherwise the function, as is, is completely unusable for its intended purpose. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
