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

R&D: Python & JS from Rust #9

Closed
cdump opened this issue Aug 13, 2024 · 2 comments
Closed

R&D: Python & JS from Rust #9

cdump opened this issue Aug 13, 2024 · 2 comments

Comments

@cdump
Copy link
Owner

cdump commented Aug 13, 2024

The amount of code is increasing, and to add new features faster, I want to research the ability to have only a Rust implementation of the EVMole and to build Python and JS libraries from that.

For Python, I want to use pyo3, and for JS - wasm-bindgen.

I spent a few hours and have a working solution. The sizes of the libraries are still not huge, and the times in benchmarks improved for both Python and WASM (JS) compared to native implementations.
In this issue, I will track R&D progress on this, collect comments with pros and cons, etc.

Still need to test installing Python packages on other architectures, because I don't want to limit it to prebuilt x86 only.

related: #5

@cdump
Copy link
Owner Author

cdump commented Aug 17, 2024

Current state:
In the wasm branch, we have some working Python & JavaScript implementations from Rust.
evmole-rs-py and evmole-rs-js benchmark targets added to test these implementations.

Benchmarks

arguments on random50k dataset:
evmole-py: 1002.4s
evmole-rs-py: 110.6s
evmole-js: 396.9s
evmole-rs-js: 290.6s

evmole-py - native python (evmole 0.3.7)
evmole-js - native javascript (evmole 0.3.7)
evmole-rs-py - wheel built using https://pyo3.rs/
evmole-rs-js - wasm built using https://github.com/rustwasm/wasm-pack

TODOs

  1. Research Uint8Array and string zero-copy arguments to improve JS (WASM) speed
  2. Add autotests for npm package with:
  • Node.js import
  • Node.js require
  • Popular bundlers: vite, webpack, ...
  • Web browsers
  1. Add autotest for Python package
  2. Write API documentation
  3. Describe requirements for Python source package for pip (how to install build requirements). We need this for architectures where we won't build a wheel package.
  4. Describe JS decisions about multiple targets (with & without top-level await), ...
  5. review GO+Wasm from Export the rust version to WASM + Use it in a Go library #10 - try to find something with "less code by hand"

Next steps

After completing the 1st TODO, we can merge this to master.
The Rust package will not be affected - all new code is hidden by --features.
The next release will still have native JavaScript & Python implementations. WASM will be available to build "by hand" to do more research and address other points from the TODO list.

@cdump
Copy link
Owner Author

cdump commented Aug 27, 2024

merged to the master

@cdump cdump closed this as completed Aug 27, 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