Skip to content

Investigate parallelization for wasm with web_worker #7

@Pratyush

Description

@Pratyush

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions