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

How to speed-up calls into rust #9686

Open
fabianmurariu opened this issue Nov 26, 2024 · 3 comments
Open

How to speed-up calls into rust #9686

fabianmurariu opened this issue Nov 26, 2024 · 3 comments

Comments

@fabianmurariu
Copy link

Project here

I'm evaluationg wasm + wasmtime for a query execution library, much of that involves calling iterators into rust to get data then executing dynamically generated logic via wasm.

The code here sums up an iterator by calling a rust function and doing the summing up in wasm

  1. is there a better way to measure the wasmtime execution time
  2. can this be made to run faster? If yes then how?

currently the run times seem to be

rust: 30ns
wasm: 21ms
python: 0.75s
@alexcrichton
Copy link
Member

At least for wasmtime you're measuring what's the fastest way. The Rust number probably isn't representative because it's probably constant-folded by LLVM which means it's not actually doing anything at runtime. The Wasm number shows an overhead of 4.2ns per call which is roughly what's expected. I'm not familiar with benchmarking Python so I don't know whether that's representative.

@fabianmurariu
Copy link
Author

I'm considering using the memory instead, can a rust function be called from WASM and write something to memory that can then be accessed in WASM?

@alexcrichton
Copy link
Member

Yes, I'd recommend reading over the examples here

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

2 participants