mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 16:37:57 +00:00
add feature wasmtime-jitdump (#9871)
* add feature wasmtime-jitdump * remove unwrap * always enable wasmtime/jitdump feature * env WASMTIME_PROFILING_STRATEGY: retun an error for unknown value * Add doc for env var WASMTIME_PROFILING_STRATEGY * Update client/executor/wasmtime/Cargo.toml Co-authored-by: Sergei Shulepov <s.pepyakin@gmail.com> * warning instead of error * Update client/executor/wasmtime/src/runtime.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * update doc: unknown value cause warning instead of error * log warning only once * static right next to the usage Co-authored-by: Sergei Shulepov <s.pepyakin@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -38,7 +38,10 @@ use sp_wasm_interface::{Function, Pointer, Value, WordSize};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
rc::Rc,
|
||||
sync::Arc,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
},
|
||||
};
|
||||
use wasmtime::{AsContext, AsContextMut, Engine, StoreLimits};
|
||||
|
||||
@@ -322,6 +325,23 @@ fn common_config(semantics: &Semantics) -> std::result::Result<wasmtime::Config,
|
||||
config.cranelift_opt_level(wasmtime::OptLevel::SpeedAndSize);
|
||||
config.cranelift_nan_canonicalization(semantics.canonicalize_nans);
|
||||
|
||||
let profiler = match std::env::var_os("WASMTIME_PROFILING_STRATEGY") {
|
||||
Some(os_string) if os_string == "jitdump" => wasmtime::ProfilingStrategy::JitDump,
|
||||
None => wasmtime::ProfilingStrategy::None,
|
||||
Some(_) => {
|
||||
// Remember if we have already logged a warning due to an unknown profiling strategy.
|
||||
static UNKNOWN_PROFILING_STRATEGY: AtomicBool = AtomicBool::new(false);
|
||||
// Make sure that the warning will not be relogged regularly.
|
||||
if !UNKNOWN_PROFILING_STRATEGY.swap(true, Ordering::Relaxed) {
|
||||
log::warn!("WASMTIME_PROFILING_STRATEGY is set to unknown value, ignored.");
|
||||
}
|
||||
wasmtime::ProfilingStrategy::None
|
||||
},
|
||||
};
|
||||
config
|
||||
.profiler(profiler)
|
||||
.map_err(|e| WasmError::Instantiation(format!("fail to set profiler: {}", e)))?;
|
||||
|
||||
if let Some(DeterministicStackLimit { native_stack_max, .. }) =
|
||||
semantics.deterministic_stack_limit
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user