cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Use gopherJS instead of webassembly for @onflow/cadence-parser

Open bluesign opened this issue 2 years ago • 4 comments

Issue To Be Solved

Currently cadence parser is compiled for webassembly, but it can be more effectively can be compiled with gopherJS. [0]

I tried running with :

~/go/bin/gopherjs build --minify ./runtime/cmd/parse

result was 2.8M pure js file. ( I just had to change tags to js from wasm , code didn't require any change )

[0] https://github.com/gopherjs/gopherjs

bluesign avatar Jul 11 '22 08:07 bluesign

Interesting, I did not know this exists! Does the resulting build work properly? What is the performance compared to the WebAssembly build?

turbolent avatar Jul 14 '22 23:07 turbolent

@turbolent let me try to parse all mainnet contracts with both of them and compare performance and correctness in the weekend.

So far in my tests working fast and correct, but can be some edge cases

bluesign avatar Jul 15 '22 08:07 bluesign

@turbolent I ran the tests ( though it was super tricky running both at the same time, so I separated and ran in 2 pass )

  • webassembly is approx 6-7x faster on Safari (though slowest gopherJS parsed was around 800-900ms)
  • I parsed around 600 contracts, there was no edge case

I think it can still worth to compile with gopherJS though, or at least can be another package.

bluesign avatar Jul 18 '22 12:07 bluesign

Nice! It's funny how size almost 1:1 correlates with speed for this one.

sideninja avatar Jul 19 '22 08:07 sideninja