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

feat: Remove caching in wasmer_wamr mode #127

Merged
merged 35 commits into from
Dec 18, 2024

Conversation

mattyg
Copy link
Member

@mattyg mattyg commented Nov 11, 2024

In wasmer_wamr mode, expose a public function build_module to build a wasm module directly, bypassing the cache.

This is a prerequisite for holochain/holochain#4441

This PR is merging into chore/cleanup-make-private for a more legible diff.

@mattyg mattyg changed the title WIP feat: expose fn to enable building a wasmer module outside of the ModuleCache feat: expose fn to enable building a wasmer module outside of the ModuleCache Dec 14, 2024
@mattyg mattyg marked this pull request as ready for review December 14, 2024 00:39
@mattyg mattyg changed the title feat: expose fn to enable building a wasmer module outside of the ModuleCache WIP feat: expose fn to enable building a wasmer module outside of the ModuleCache Dec 14, 2024
@mattyg mattyg changed the title WIP feat: expose fn to enable building a wasmer module outside of the ModuleCache WIP feat: Remove caching in wasmer_wamr mode Dec 14, 2024
Compile(String),
/// Wasmer failed to build a Module from wasm byte code.
/// With the feature `wasmer_sys` enabled, building a Module includes compiling the wasm.
ModuleBuild(String),
Copy link
Member Author

@mattyg mattyg Dec 14, 2024

Choose a reason for hiding this comment

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

Rename error type to clarify that it is an error arising when creating a new wasmer Module. Only in wasmer_sys mode does compilation occur here.

use super::build_module;

#[test]
fn build_module_test() {
Copy link
Member Author

Choose a reason for hiding this comment

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

smoke test for building a wasm module in wasmer_wamr mode.

@mattyg mattyg changed the base branch from main to chore/cleanup-make-private December 14, 2024 19:08
@@ -54,6 +54,11 @@ pub(crate) fn make_runtime_engine() -> Engine {
Engine::headless()
}

/// Build an interpreter module from wasm bytes.
pub fn build_module(_wasm: &[u8]) -> Result<Arc<Module>, wasmer::RuntimeError> {
unimplemented!("The feature flag 'wasmer_wamr' must be enabled to support building a Module directly. Please use the ModuleCache instead.");
Copy link
Member Author

@mattyg mattyg Dec 14, 2024

Choose a reason for hiding this comment

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

This is keep a consistent api so we don't need to use conditional feature flags in the consumer.

I recognize this is silly, since the function below build_module_for_ios does the same thing. But for clarity I'd like to wait to remove that til we remove the "prebuilt ios modules" functionality in its entirety.

@mattyg mattyg requested a review from a team December 14, 2024 19:40
@mattyg mattyg changed the title WIP feat: Remove caching in wasmer_wamr mode feat: Remove caching in wasmer_wamr mode Dec 14, 2024
Base automatically changed from chore/cleanup-make-private to main December 16, 2024 22:05
Copy link
Member

@ThetaSinner ThetaSinner left a comment

Choose a reason for hiding this comment

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

Not sure how much value I'm providing with a review here but the reason for the change makes sense and all the code changes seem consistent with the goal and each other :)

crates/common/src/result.rs Outdated Show resolved Hide resolved
crates/host/src/module.rs Outdated Show resolved Hide resolved
crates/host/src/module.rs Outdated Show resolved Hide resolved
@mattyg mattyg merged commit c6d0e71 into main Dec 18, 2024
13 checks passed
@mattyg mattyg deleted the feat/support-build-module-outside-cache branch December 18, 2024 17:50
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