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

Speed up execution of zkAsm code from Rust #227

Open
4 tasks
aborg-dev opened this issue Feb 21, 2024 · 0 comments
Open
4 tasks

Speed up execution of zkAsm code from Rust #227

aborg-dev opened this issue Feb 21, 2024 · 0 comments

Comments

@aborg-dev
Copy link

Discussed in https://github.com/orgs/0xPolygonHermez/discussions/66

Originally posted by akashin February 7, 2024

Context

As a part of ZK WASM compiler (https://github.com/near/wasmtime) written in Rust we are compiling WASM code (tests like this one) to zkAsm and want to execute the resulting zkAsm code.

At the moment, we use a nodejs interpreter to run each zkAsm file using this script. This provides the necessary functionality, but the startup time of npm run is around 700ms which would likely be too slow when we have more than 100 tests. We want to find a way to run these tests faster. We can't easily batch the execution into a single invocation of npm run as zkAsm files are generated on the fly by Rust tests that run in parallel.

One of the ideas was to use https://deno.com/ runtime to run the JS code. This way it could be possible to embed Deno runtime into Rust binary which would remove the overheads of starting a subprocess. I did a quick prototype but it would require some changes to zkAsm codebase.

See https://near.zulipchat.com/#narrow/stream/295306-pagoda.2Fcontract-runtime/topic/Running.20zkAsm.20code.20from.20Rust for full discussion.

Next steps

  • Measure the current execution time for tests
  • Try bun nodejs runner
  • Try bundling Nodejs code before executing it
  • Try using Deno for execution
@aborg-dev aborg-dev added this to the ZK WASM: Stage 2 milestone Feb 21, 2024
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

1 participant