Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.