Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm:@node-rs/argon2 is faster in Deno #19

Open
brettchalupa opened this issue Dec 27, 2024 · 1 comment
Open

npm:@node-rs/argon2 is faster in Deno #19

brettchalupa opened this issue Dec 27, 2024 · 1 comment

Comments

@brettchalupa
Copy link

brettchalupa commented Dec 27, 2024

Thank you so much for continuing on with maintaining this project and publishing it on JSR. It's been useful for hashing and verifying passwords in my Deno project. 🦕

I was doing some various benchmarks with different packages, and I thought I'd include npm:@node-rs/argon2.

From my benchmark (source), I'm seeing that npm:@node-rs/argon2 is about 1.4x faster than @felix/argon2:

    CPU | Apple M3
Runtime | Deno 2.1.4 (aarch64-apple-darwin)

benchmark                                            time/iter (avg)        iter/s      (min … max)           p75      p99     p995
---------------------------------------------------- ----------------------------- --------------------- --------------------------

group argon2
Hash and Verify - @felix/argon2 (Rust FFI)                   32.9 ms          30.4 ( 30.8 ms …  43.9 ms)  32.5 ms  43.9 ms  43.9 ms
Hash and Verify - @stdext/crypto > argon2 (WASM)             71.5 ms          14.0 ( 70.6 ms …  74.6 ms)  71.7 ms  74.6 ms  74.6 ms
Hash and Verify - @stdext/crypto > argon2i (WASM)            72.1 ms          13.9 ( 70.9 ms …  73.9 ms)  72.8 ms  73.9 ms  73.9 ms
Hash and Verify - @stdext/crypto > argon2id (WASM)           73.9 ms          13.5 ( 71.0 ms …  77.8 ms)  75.4 ms  77.8 ms  77.8 ms
Hash and Verify - @rabbit-company/argon2id (WASM)           416.3 ms           2.4 (413.3 ms … 422.9 ms) 415.4 ms 422.9 ms 422.9 ms
Hash and Verify - @ts-rex/argon2 (WASM)                      83.8 ms          11.9 ( 82.5 ms …  86.0 ms)  84.4 ms  86.0 ms  86.0 ms
Hash and Verify - npm:argon2 (C FFI)                         62.4 ms          16.0 ( 58.8 ms …  70.5 ms)  63.7 ms  70.5 ms  70.5 ms
Hash and Verify - npm:@node-rs/argon2 (Rust FFI)             23.6 ms          42.4 ( 22.5 ms …  27.0 ms)  23.6 ms  27.0 ms  27.0 ms

summary
  Hash and Verify - npm:@node-rs/argon2 (Rust FFI)
     1.40x faster than Hash and Verify - @felix/argon2 (Rust FFI)
     2.65x faster than Hash and Verify - npm:argon2 (C FFI)
     3.04x faster than Hash and Verify - @stdext/crypto > argon2 (WASM)
     3.06x faster than Hash and Verify - @stdext/crypto > argon2i (WASM)
     3.13x faster than Hash and Verify - @stdext/crypto > argon2id (WASM)
     3.56x faster than Hash and Verify - @ts-rex/argon2 (WASM)
    17.67x faster than Hash and Verify - @rabbit-company/argon2id (WASM)

I share this not to say: hey, look, this other thing is faster! But was wondering why that would be?

Is it the difference between the argon2 crate (which npm:@node-rs/argon2 uses) and rust-argon2, which this project uses?

Thought it was interesting and that I'd share it.

@felix-schindler
Copy link
Owner

Thanks, I'll check it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants