paulmillr / noble-hashes

Audited & minimal JS implementation of hash functions, MACs and KDFs.
https://paulmillr.com/noble
MIT License
545 stars 46 forks source link

Benchmarks are slowed down when other modules are imported #91

Open paulmillr opened 2 months ago

paulmillr commented 2 months ago

I've spotted this after benchmarks were transitioned from common.js to ESM in 88c1aa30674348f497f936e497d734a15f53be26. Check out main branch.

We need to investigate:

  1. Why sha3 is 25% slower when other modules are imported
  2. Why sha2 is NOT slower when other modules are imported. What's special about sha3?
  3. Why everything was fine with common.js, but is slow with ESM?
  4. Bonus issue: re-exporting isBytes slows-down performance considerably. See branch https://github.com/paulmillr/noble-hashes/tree/import-perf. Probably related.

To investigate this, v8/node.js profiling, memory dumps, etc may help.