Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

add feature wasmtime-jitdump #9871

Merged
merged 12 commits into from
Sep 29, 2021
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/executor/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" }
sc-allocator = { version = "4.0.0-dev", path = "../../allocator" }
wasmtime = { version = "0.27.0", default-features = false, features = [
"cache",
"jitdump",
"parallel-compilation",
] }

Expand Down
12 changes: 11 additions & 1 deletion client/executor/wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

/// ! 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 | error |

mod host;
mod imports;
mod instance_wrapper;
Expand Down
12 changes: 12 additions & 0 deletions client/executor/wasmtime/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ 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,
Some(_) => {
log::warn!("WASMTIME_PROFILING_STRATEGY is set to unknown value, ignored.");
pepyakin marked this conversation as resolved.
Show resolved Hide resolved
wasmtime::ProfilingStrategy::None
},
None => wasmtime::ProfilingStrategy::None,
};
config
.profiler(profiler)
.map_err(|e| WasmError::Instantiation(format!("fail to set jitdump profiler: {}", e)))?;
librelois marked this conversation as resolved.
Show resolved Hide resolved

if let Some(DeterministicStackLimit { native_stack_max, .. }) =
semantics.deterministic_stack_limit
{
Expand Down