Daninet / hash-wasm

Lightning fast hash functions using hand-tuned WebAssembly binaries
https://npmjs.com/package/hash-wasm
Other
881 stars 49 forks source link

Is there any way to optimize it? #50

Open envdevprod opened 1 year ago

envdevprod commented 1 year ago

Hello, Daninet. I'm currently using this library in a Vue project and I want to calculate the SM3 hash of files in Chrome. However, I've noticed that the calculation speed is not very fast for large video files, especially those over 7GB. Is there any way to optimize it?

Daninet commented 1 year ago

The library should archive consistent speeds even with files larger than 7GB. The performance might be affected by disk I/O. SSD / HDD read speeds might be slower than the hashing.

IVLIU commented 9 months ago

I used a PDF file of about 110MB for testing. js took about 400ms and wasm about 700ms. Is there a threshold and wasm is faster than js?

Daninet commented 9 months ago

According to my measurements the threshold is at a few kilobytes and in the other direction and when it's not warmed up. I mean JS might be faster with 1kb of data when the wasm binary is not optimized yet. Do you have the chrome dev tools open? That has a large impact on WASM performance.

IVLIU commented 9 months ago

According to my measurements the threshold is at a few kilobytes and in the other direction and when it's not warmed up. I mean JS might be faster with 1kb of data when the wasm binary is not optimized yet. Do you have the chrome dev tools open? That has a large impact on WASM performance.

Yes, I opened it, I need to retest