arkworks-rs / arkworks-rs/std

Investigate parallelization for wasm with `web_worker`

Open
#7 1 comment 4 reactions 1 assignee Claimed by @Pratyush View on GitHub
Dominant language
Rust
Stars
42
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Use [`web_worker`](https://github.com/amethyst/web_worker) to create a new `rayon::ThreadPool` to enable parallelization on `wasm`.

The `wasm` app will need a initialization for the global ThreadPool, so probably something like this:

```rust
fn set_global_pool_to_web_workers() {
let concurrency = match web_sys::window() {
Some(window) => window.navigator().hardware_concurrency() as usize,
None => {
console_log!("Failed to get hardware concurrency from window. This function is only available in the main browser thread.");
2
}
};
let worker_pool = pool::WorkerPool::new(concurrency);
rayon::ThreadPoolBuilder::new()
.num_threads(concurrency)
.spawn_handler(|thread| Ok(pool.run(|| thread.run()).unwrap()))
.build()?;
}
```

cc @kobigurk @howardwu, this is of interest for speeding up proving and setup ceremonies in the browser.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.