Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/examples/fast_compilation.rs
1685 views
1
//! Tuning Wasmtime for fast compilation.
2
//!
3
//! If your application design is compatible with pre-compiling Wasm programs,
4
//! prefer doing that.
5
6
use wasmtime::{Cache, Config, Engine, Result, Strategy};
7
8
fn main() -> Result<()> {
9
let mut config = Config::new();
10
11
// Enable the compilation cache, using the default cache configuration
12
// settings.
13
config.cache(Some(Cache::from_file(None)?));
14
15
// Enable Winch, Wasmtime's baseline compiler.
16
config.strategy(Strategy::Winch);
17
18
// Enable parallel compilation.
19
config.parallel_compilation(true);
20
21
// Build an `Engine` with our `Config` that is tuned for fast Wasm
22
// compilation.
23
let engine = Engine::new(&config)?;
24
25
// Now we can use `engine` to compile and/or run some Wasm programs...
26
27
let _ = engine;
28
Ok(())
29
}
30
31