Enable jitdump profiling support by default (#1310)
* Enable jitdump profiling support by default This the result of some of the investigation I was doing for #1017. I've done a number of refactorings here which culminated in a number of changes that all amount to what I think should result in jitdump support being enabled by default: * Pass in a list of finished functions instead of just a range to ensure that we're emitting jit dump data for a specific module rather than a whole `CodeMemory` which may have other modules. * Define `ProfilingStrategy` in the `wasmtime` crate to have everything locally-defined * Add support to the C API to enable profiling * Documentation added for profiling with jitdump to the book * Split out supported/unsupported files in `jitdump.rs` to avoid having lots of `#[cfg]`. * Make dependencies optional that are only used for `jitdump`. * Move initialization up-front to `JitDumpAgent::new()` instead of deferring it to the first module. * Pass around `Arc<dyn ProfilingAgent>` instead of `Option<Arc<Mutex<Box<dyn ProfilingAgent>>>>` The `jitdump` Cargo feature is now enabled by default which means that our published binaries, C API artifacts, and crates will support profiling at runtime by default. The support I don't think is fully fleshed out and working but I think it's probably in a good enough spot we can get users playing around with it!
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
use crate::{wasm_byte_vec_t, wasm_config_t, wasm_engine_t};
|
||||
use std::str;
|
||||
use wasmtime::{OptLevel, Strategy};
|
||||
use wasmtime::{OptLevel, ProfilingStrategy, Strategy};
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone)]
|
||||
@@ -21,6 +21,13 @@ pub enum wasmtime_opt_level_t {
|
||||
WASMTIME_OPT_LEVEL_SPEED_AND_SIZE,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone)]
|
||||
pub enum wasmtime_profiling_strategy_t {
|
||||
WASMTIME_PROFILING_STRATEGY_NONE,
|
||||
WASMTIME_PROFILING_STRATEGY_JITDUMP,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasmtime_config_debug_info_set(c: *mut wasm_config_t, enable: bool) {
|
||||
(*c).config.debug_info(enable);
|
||||
@@ -88,6 +95,18 @@ pub unsafe extern "C" fn wasmtime_config_cranelift_opt_level_set(
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasmtime_config_profiler_set(
|
||||
c: *mut wasm_config_t,
|
||||
strategy: wasmtime_profiling_strategy_t,
|
||||
) {
|
||||
use wasmtime_profiling_strategy_t::*;
|
||||
drop((*c).config.profiler(match strategy {
|
||||
WASMTIME_PROFILING_STRATEGY_NONE => ProfilingStrategy::None,
|
||||
WASMTIME_PROFILING_STRATEGY_JITDUMP => ProfilingStrategy::JitDump,
|
||||
}));
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wasmtime_wat2wasm(
|
||||
_engine: *mut wasm_engine_t,
|
||||
|
||||
Reference in New Issue
Block a user