Skip to content

Commit

Permalink
Use a spinner to show that wasm is compiling in spacetime generate (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 authored Jan 7, 2025
1 parent 2967e3b commit 2b227fe
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions crates/cli/src/subcommands/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ pub async fn exec(config: Config, args: &clap::ArgMatches) -> anyhow::Result<()>
} else {
build::exec_with_argstring(config.clone(), project_path, build_options).await?
};
extract_descriptions(&wasm_path)?
let spinner = indicatif::ProgressBar::new_spinner();
spinner.enable_steady_tick(60);
spinner.set_message("Compiling wasm...");
let module = compile_wasm(&wasm_path)?;
spinner.set_message("Extracting schema from wasm...");
extract_descriptions_from_module(module)?
};

fs::create_dir_all(out_dir)?;
Expand Down Expand Up @@ -368,16 +373,22 @@ impl GenItem {
}

pub fn extract_descriptions(wasm_file: &Path) -> anyhow::Result<RawModuleDef> {
let engine = wasmtime::Engine::default();
let t = std::time::Instant::now();
let module = wasmtime::Module::from_file(&engine, wasm_file)?;
println!("compilation took {:?}", t.elapsed());
let module = compile_wasm(wasm_file)?;
extract_descriptions_from_module(module)
}

fn compile_wasm(wasm_file: &Path) -> anyhow::Result<wasmtime::Module> {
wasmtime::Module::from_file(&wasmtime::Engine::default(), wasm_file)
}

fn extract_descriptions_from_module(module: wasmtime::Module) -> anyhow::Result<RawModuleDef> {
let engine = module.engine();
let ctx = WasmCtx {
mem: None,
sink: Vec::new(),
};
let mut store = wasmtime::Store::new(&engine, ctx);
let mut linker = wasmtime::Linker::new(&engine);
let mut store = wasmtime::Store::new(engine, ctx);
let mut linker = wasmtime::Linker::new(engine);
linker.allow_shadowing(true).define_unknown_imports_as_traps(&module)?;
let module_name = &*format!("spacetime_{MODULE_ABI_MAJOR_VERSION}.0");
linker.func_wrap(
Expand Down

1 comment on commit 2b227fe

@github-actions
Copy link

@github-actions github-actions bot commented on 2b227fe Jan 7, 2025

Choose a reason for hiding this comment

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

Criterion benchmark results

Error when comparing benchmarks: Couldn't find AWS credentials in environment, credentials file, or IAM role.

Caused by:
Couldn't find AWS credentials in environment, credentials file, or IAM role.

Please sign in to comment.