onflow / cadence

Cadence, the resource-oriented smart contract programming language 🏃‍♂️
https://developers.flow.com/cadence
Apache License 2.0
532 stars 139 forks source link

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

Open bluesign opened 2 years ago

bluesign commented 2 years ago

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

turbolent commented 2 years ago

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

bluesign commented 2 years ago

@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 commented 2 years ago

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

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

sideninja commented 2 years ago

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