Pluggable memory allocator (for Argon2) #1472
MaxKellermann
started this conversation in
Ideas
Replies: 1 comment
-
|
Interesting. The ability to override memory-allocation functions is also valuable for WebAssembly. Integration with the existing sodium_malloc could be tricky, but it’s feasible. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Each call to
crypto_pwhash_str_verify()allocates/frees a large memory block withmmap()/munmap(). This adds a lot of overhead to the function, plus it limits parallelization due to lock contention (in the Linux kernel): on a 24-core machine, I was able to saturate less than 6 cores.With a quick'n'dirty patch which implements a per-thread cache for the last allocation (MaxKellermann@cache_mmap), I was able to saturate 23 cores.
This is a scalability problem that could be fixed by allowing applications to replace the allocation function, leaving the current scheme as the default, and those who need the scalability (in return for memory overhead) can plug in their own allocator like the one on my PoC patch.
I volunteer to implement this feature, but I'd like to know whether that would be accepted for merging here. If not, we'll just use my patch instead of writing a general-purpose solution for everybody.
Beta Was this translation helpful? Give feedback.
All reactions