Add timing instrumentation
This commit is contained in:
parent
2c637b83bf
commit
61f5326033
3 changed files with 57 additions and 46 deletions
|
@ -10,7 +10,7 @@ Wasm plugins can be run through `wasmtime`, with supported for sandboxed system
|
|||
## ABI
|
||||
The interface between the host Rust runtime ('Runtime') and plugins implemented in Wasm ('Plugin') is pretty simple.
|
||||
|
||||
`Buffer` is a pair of two 4-byte (`u32`) fields:
|
||||
`Buffer` is a pair of two 4-byte (`u32`) fields, encoded as a single `u64`.
|
||||
|
||||
```
|
||||
struct Buffer {
|
||||
|
@ -21,7 +21,7 @@ struct Buffer {
|
|||
|
||||
All functions that Plugin exports must have the following properties:
|
||||
|
||||
- Have the signature `fn(ptr: u32, len: u32) -> u32`, where the return type is a pointer to a `Buffer`, and the arguments are the component parts of a `Buffer`.
|
||||
- Have the signature `fn(ptr: u64) -> u64`, where both the argument and return types are a `Buffer`:
|
||||
|
||||
- The input `Buffer` will contain the input arguments serialized to `bincode`.
|
||||
- The output `Buffer` will contain the output arguments serialized to `bincode`.
|
||||
|
|
|
@ -69,8 +69,12 @@ impl PluginBuilder {
|
|||
dbg!("new plugin");
|
||||
let mut config = Config::default();
|
||||
config.async_support(true);
|
||||
dbg!("Creating engine");
|
||||
let start = std::time::Instant::now();
|
||||
let engine = Engine::new(&config)?;
|
||||
dbg!(start.elapsed());
|
||||
let linker = Linker::new(&engine);
|
||||
dbg!(start.elapsed());
|
||||
|
||||
Ok(PluginBuilder {
|
||||
// host_functions: HashMap::new(),
|
||||
|
@ -306,6 +310,8 @@ impl Plugin {
|
|||
|
||||
// create a store, note that we can't initialize the allocator,
|
||||
// because we can't grab the functions until initialized.
|
||||
dbg!("Creating store");
|
||||
let start = std::time::Instant::now();
|
||||
let mut store: Store<WasiCtxAlloc> = Store::new(
|
||||
&engine,
|
||||
WasiCtxAlloc {
|
||||
|
@ -313,12 +319,20 @@ impl Plugin {
|
|||
alloc: None,
|
||||
},
|
||||
);
|
||||
let module = Module::new(&engine, module)?;
|
||||
dbg!("created store");
|
||||
dbg!(start.elapsed());
|
||||
|
||||
let module = Module::new(&engine, module)?;
|
||||
// load the provided module into the asynchronous runtime
|
||||
linker.module_async(&mut store, "", &module).await?;
|
||||
dbg!("Instantiating module");
|
||||
let start = std::time::Instant::now();
|
||||
let instance = linker.instantiate_async(&mut store, &module).await?;
|
||||
let end = dbg!(start.elapsed());
|
||||
|
||||
dbg!("Instantiating second module");
|
||||
let start = std::time::Instant::now();
|
||||
let instance2 = linker.instantiate_async(&mut store, &module).await?;
|
||||
let end = dbg!(start.elapsed());
|
||||
|
||||
// now that the module is initialized,
|
||||
// we can initialize the store's allocator
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue