storacha / w3cli

💾 w3 command line interface
Other
35 stars 7 forks source link

feat: use worker thread for piece hashing #198

Closed alanshaw closed 1 day ago

alanshaw commented 4 months ago

Worker threads actually share memory in Node.js so there's no copy getting the CAR bytes into the worker. This allows WASM piece hashing in a worker that doesn't stall the main thread.

Before

Notice how the spinner is stalled for multiple seconds as piece hashing is done:

https://github.com/storacha-network/w3cli/assets/152863/5d88f8c5-e7ae-4da3-96ce-a686fb3f2258

After

No stall!

https://github.com/storacha-network/w3cli/assets/152863/747a412e-1c27-456b-913f-a4ec6e29498a