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

Investigate parallelization for wasm with web_worker #7

Open
Pratyush opened this issue Aug 26, 2020 · 1 comment
Open

Investigate parallelization for wasm with web_worker #7

Pratyush opened this issue Aug 26, 2020 · 1 comment
Assignees

Comments

@Pratyush
Copy link
Member

Use 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:

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.

@Pratyush Pratyush self-assigned this Aug 26, 2020
@Pratyush Pratyush transferred this issue from arkworks-rs/snark Nov 20, 2020
@Pratyush
Copy link
Member Author

This makes it even easier to use rayon in wasm: https://github.com/GoogleChromeLabs/wasm-bindgen-rayon/

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