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

Mention WebAssembly? #51

Closed
kripken opened this issue Feb 4, 2018 · 6 comments
Closed

Mention WebAssembly? #51

kripken opened this issue Feb 4, 2018 · 6 comments

Comments

@kripken
Copy link
Contributor

kripken commented Feb 4, 2018

Now that there is optional wasm optimization here, maybe it's worth mentioning that on the main page here and on https://www.npmjs.com/package/long ?

@dcodeIO
Copy link
Owner

dcodeIO commented Feb 4, 2018

Sure, why not :) Currently it's in the release notes only.

@dcodeIO
Copy link
Owner

dcodeIO commented Feb 4, 2018

What do you think of adding this paragrapth below the API:


WebAssembly support

WebAssembly supports 64-bit integer arithmetic out of the box, hence a tiny WebAssembly module is used to compute operations like multiplication, division and remainder more efficiently (slow operations like division are around twice as fast), falling back to floating point based computations in JavaScript where WebAssembly is not yet supported, e.g., in older versions of node.

@xtuc
Copy link

xtuc commented Feb 4, 2018

I guess there's also a performance gain, you could talk about it too.

@kripken
Copy link
Contributor Author

kripken commented Feb 5, 2018

I did some more careful measurements now, I see the following speedups when using wasm:

  • Multiply is 8-15% faster
  • Divide is 33-45% faster
  • Modulo is 45%-65% faster

(the range is from comparing on a bunch of different VMs).

I think this could be summarized as "slow operations like division are around twice as fast".

@dcodeIO dcodeIO closed this as completed in 9dec515 Feb 6, 2018
@dcodeIO
Copy link
Owner

dcodeIO commented Feb 7, 2018

Alright, the updated paragraph above is in the README now. It's not possible to just switch the README on npm, though, so we'll have to wait for another version update. Maybe implementing ctz, clz, rotl, rotr (see #45) and maybe others might be a good cause :)

@xtuc
Copy link

xtuc commented Feb 7, 2018

@dcodeIO I think this information is important enough to make a new release to update the README on npm (even if it's just a patch).

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

3 participants