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

πŸ› οΈ [TASK] : WASM Module::call_func implementation parallelisation #81

Open
Tracked by #203
Mr-Leshiy opened this issue Feb 3, 2024 · 3 comments
Open
Tracked by #203
Assignees

Comments

@Mr-Leshiy
Copy link
Contributor

Summary

Parallelise Module::call_func function implementation

Description

Run an internal implementation of the Module::call_func in the separate thread.
Under the separate thread execution should be moved WASM Store initialisation, wasm module instantiation, and wasm function call.

    pub(crate) fn call_func<Args, Ret>(
        &mut self, name: &str, args: Args,
    ) -> Result<Ret, Box<dyn Error>>
    where
        Args: WasmParams,
        Ret: WasmResults,
    {
        self.context.use_for(name.to_string());
        std::thread::spawn(|| {
            let mut store = WasmStore::new(&self.engine, self.context.clone());
            let instance = self.pre_instance.instantiate(&mut store)?;
            let func = instance.get_typed_func(&mut store, name)?;
            Ok(func.call(&mut store, args)?)
        });
    }
@Mr-Leshiy Mr-Leshiy moved this to πŸ”– Ready in Catalyst Feb 3, 2024
@Mr-Leshiy Mr-Leshiy self-assigned this Feb 3, 2024
@stevenj
Copy link
Collaborator

stevenj commented Feb 5, 2024

Based on my work with the WASM Component Model code generation, it may impact this work.
We should probably look at integration with that first.
WASM component model autogenerates the calls to the functions defined by the component model .wit files.
See the example I have on calling using WASM Component model bindings.

@Mr-Leshiy Mr-Leshiy moved this from πŸ”– Ready to πŸ— In progress in Catalyst Feb 5, 2024
@Mr-Leshiy Mr-Leshiy moved this from πŸ— In progress to πŸ”– Ready in Catalyst Feb 6, 2024
@stevenj stevenj added this to the M2: Hermes Foundations milestone Mar 7, 2024
@stevenj
Copy link
Collaborator

stevenj commented Mar 7, 2024

This needs to work by running the wasm module execute in a threadpool.
Such that we can't have more wasm modules running than threads in the pool.
The pool needs to be sized to the number of hardware threads in the computer -2. And a minimum of 1 (in the case of a computer with < 4 hardware threads).

@Mr-Leshiy Mr-Leshiy moved this from πŸ”– Ready to πŸ“‹ Backlog in Catalyst Mar 20, 2024
@Mr-Leshiy
Copy link
Contributor Author

@Mr-Leshiy need to update description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: πŸ“‹ Backlog
Development

Successfully merging a pull request may close this issue.

2 participants