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

Make WasmtimeEngine a marker struct #782

Merged
merged 4 commits into from
Jan 3, 2025

Conversation

jprendes
Copy link
Collaborator

@jprendes jprendes commented Dec 28, 2024

This PR makes the WasmtimeEngine a marker struct which is very cheap to create.
This is in preparation for the Zygote work.

@jprendes jprendes force-pushed the maker-wasmtime branch 2 times, most recently from eecc7b7 to a70fc6c Compare December 30, 2024 17:59
@jprendes jprendes marked this pull request as ready for review December 30, 2024 18:32
@jprendes
Copy link
Collaborator Author

Wasmtime benchmark results are:
end-to-end/wasmtime/wasi-demo-app:latest: 131_303_173 ± 2_909_033 (last scheduled was 141_392_294 ± 3_279_112)
end-to-end/wasmtime/wasi-demo-oci:latest: 80_400_136 ± 1_424_339 (last scheduled was 97_305_557 ± 3_055_651)
aead_chacha20poly13052/Wasmtime: 121_648_447 ± 1_539_026 (last scheduled was 128_098_875 ± 1_606_609)

so it seems that performance is not degraded

Copy link
Member

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

question: why do we want to make the wasmtime engine a marker struct? You've mentioned this work is a preparation for the Zygote work. Could you please elaborate?

@jprendes
Copy link
Collaborator Author

jprendes commented Jan 2, 2025

When we introduce the zygote, we won't be able to clone the WasmtimeEngine from the shim to the child process, as the code will be executed in a different process.
This means that we need to create a new WasmtimeEngine rather than cloning.
However, we currently need a WasmtimeEngine in the shim to handle precompilation.
Making it a marker struct (i.e., a struct with no fields) means that it's not only cheap to clone, but also cheap to create.
This also allows us to use slightly different wasmtime::Engines for precompilation and for execution (e.g., we don't need pool allocator for precompilation).

@Mossaka Mossaka merged commit 94751dc into containerd:main Jan 3, 2025
72 checks passed
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.

2 participants