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

Fix wasmtime precompilation #700

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andreiltd
Copy link
Contributor

Check the wasm binary type and choose proper precompilation method.

Comment on lines +122 to +130
let compiled_layer = match WasmBinaryType::from_bytes(&layer.layer) {
Some(Module) => self.engine.precompile_module(&layer.layer)?,
Some(Component) => self.engine.precompile_component(&layer.layer)?,
None => {
log::warn!("Unknow WASM binary type");
continue;
}
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest: move this logic to Engine and add a method called fn precompile(). It is the job of the engine to handle the type of compiled_layer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead of Engine::precompile like we have now, it would be Engine::precompile_module and Engine::precompile_component?
Sounds god to me.
Alternatively, a layer could have a is_component(&self) -> bool method, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is the job of the engine to handle the type of compiled_layer

Not sure I understand this statement. note we have this type of logix else where in this shim https://github.com/andreiltd/runwasi/blob/e07255e7d1b6ea07ff3daa783782defd317d18b5/crates/containerd-shim-wasmtime/src/instance.rs#L258-L259

it would be Engine::precompile_module and Engine::precompile_component?
I am not excited about chaning the api or making the engine have to iterate through the layers. We delegate that to the instance so shims can handle there own layer types.

Alternatively, a layer could have a is_component(&self) -> bool method, WDYT?

Something like this makes sense if we want to move the logic our of here. Maybe a enum instead of a bool though? In spin shim it currently supports of ther layer types. We don't really wanto

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

Successfully merging this pull request may close these issues.

4 participants