Skip to content

Commit

Permalink
Check if layer is already precompiled before precompilation
Browse files Browse the repository at this point in the history
Signed-off-by: Kate Goldenring <[email protected]>
  • Loading branch information
kate-goldenring committed Feb 28, 2024
1 parent 56ee4e2 commit 2639c1c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions containerd-shim-spin/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,21 @@ impl Engine for SpinEngine {
}

fn precompile(&self, layer: &WasmLayer) -> Option<Result<Vec<u8>>> {
log::info!(
"Precompiling layer with Spin Engine: {:?}",
layer.config.digest()
);

match layer.config.media_type() {
MediaType::Other(name) => {
log::info!("Precompiling layer {:?}", layer.config.digest());
log::info!(
"Precompiling layer with Spin Engine: {:?}",
layer.config.digest()
);
if name == "application/vnd.wasm.content.layer.v1+wasm" {
if self
.wasmtime_engine
.detect_precompiled(&layer.layer)
.is_some()
{
log::info!("Layer already precompiled {:?}", layer.config.digest());
return None;
}
let component =
spin_componentize::componentize_if_necessary(&layer.layer).unwrap();
Some(self.wasmtime_engine.precompile_component(&component))
Expand Down

0 comments on commit 2639c1c

Please sign in to comment.