diff --git a/Cargo.lock b/Cargo.lock
index cdde834261870..0e3f3399dbf6c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -8691,6 +8691,26 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
+[[package]]
+name = "scroll"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec"
+dependencies = [
+ "scroll_derive",
+]
+
+[[package]]
+name = "scroll_derive"
+version = "0.10.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aaaae8f38bb311444cfb7f1979af0bc9240d95795f75f9ceddf6a59b79ceffa0"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
[[package]]
name = "sct"
version = "0.6.0"
@@ -11609,8 +11629,11 @@ checksum = "21486cfb5255c2069666c1f116f9e949d4e35c9a494f11112fa407879e42198d"
dependencies = [
"anyhow",
"cfg-if 1.0.0",
+ "gimli 0.25.0",
"lazy_static",
"libc",
+ "object 0.26.0",
+ "scroll",
"serde",
"target-lexicon 0.12.0",
"wasmtime-environ",
diff --git a/client/executor/wasmtime/Cargo.toml b/client/executor/wasmtime/Cargo.toml
index edf1747524263..c122b3ab0e696 100644
--- a/client/executor/wasmtime/Cargo.toml
+++ b/client/executor/wasmtime/Cargo.toml
@@ -23,7 +23,11 @@ sp-wasm-interface = { version = "4.0.0-dev", path = "../../../primitives/wasm-in
sp-runtime-interface = { version = "4.0.0-dev", path = "../../../primitives/runtime-interface" }
sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" }
sc-allocator = { version = "4.0.0-dev", path = "../../allocator" }
-wasmtime = { version = "0.29.0", default-features = false, features = ["cache", "parallel-compilation"] }
+wasmtime = { version = "0.29.0", default-features = false, features = [
+ "cache",
+ "jitdump",
+ "parallel-compilation",
+] }
[dev-dependencies]
sc-runtime-test = { version = "2.0.0", path = "../runtime-test" }
diff --git a/client/executor/wasmtime/src/lib.rs b/client/executor/wasmtime/src/lib.rs
index 8d7f93fecb307..e0d6a262afda9 100644
--- a/client/executor/wasmtime/src/lib.rs
+++ b/client/executor/wasmtime/src/lib.rs
@@ -16,7 +16,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-/// ! Defines a `WasmRuntime` that uses the Wasmtime JIT to execute.
+//! Defines a `WasmRuntime` that uses the Wasmtime JIT to execute.
+//!
+//! You can choose a profiling strategy at runtime with
+//! environment variable `WASMTIME_PROFILING_STRATEGY`:
+//!
+//! | `WASMTIME_PROFILING_STRATEGY` | Effect |
+//! |-------------|-------------------------|
+//! | undefined | No profiling |
+//! | `"jitdump"` | jitdump profiling |
+//! | other value | No profiling (warning) |
+
mod host;
mod imports;
mod instance_wrapper;
diff --git a/client/executor/wasmtime/src/runtime.rs b/client/executor/wasmtime/src/runtime.rs
index 006f102926ecb..a62356357b1f4 100644
--- a/client/executor/wasmtime/src/runtime.rs
+++ b/client/executor/wasmtime/src/runtime.rs
@@ -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::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
{