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

Working WASM build of parcnet-pod #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

robknight
Copy link

This is an experiment, shared for visibility. Not sure if we want to merge this or not.

I wanted to figure out:
a) how hard is it to get a working Wasm build of a Rust crate
b) what is the difference in performance between Rust/Wasm code and JS code for a small but non-trivial task (in this case, signing a POD1)

The answer to (a) is "not very difficult but there are some weird issues that require some knowledge to fix".

The answer to (b) is that the Wasm performance is notably worse than the JS performance.

Signing a POD1 using the @pcd/pod package takes just under 50ms on my Macbook Air M1, and requires around 100KiB of JavaScript dependencies.

Signing a POD1 using parcnet-pod in Wasm takes around 250-280ms on my Macbook Air M1, and requires around 1.6MiB of Wasm to do so. This is quite a lot worse than I expected.

Since parcnet-pod has benchmark tests in Rust, I also tried those, which show that even in natively-compiled Rust, a small POD1 takes 80ms to sign. I am not sure why this is slower than it is in JavaScript.

Perhaps the lesson to take from this is that our JavaScript toolchain is a bit more highly-evolved, depending on packages which have already been optimized for both performance and size, whereas our Rust code has not, and our Wasm toolchain is non-existent until now. Hopefully this means that there is low-hanging fruit for speed and size improvement.

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

Successfully merging this pull request may close these issues.

1 participant