Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x64: enable VTune support by default #3821

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ default = [
"jitdump",
"wasmtime/wat",
"wasmtime/parallel-compilation",
"vtune",
"wasi-nn",
"pooling-allocator",
"memfd",
Expand Down
2 changes: 1 addition & 1 deletion crates/jit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ gimli = { version = "0.26.0", default-features = false, features = ["std", "read
object = { version = "0.27.0", default-features = false, features = ["std", "read_core", "elf"] }
serde = { version = "1.0.94", features = ["derive"] }
addr2line = { version = "0.17.0", default-features = false }
ittapi-rs = { version = "0.1.6", optional = true }
ittapi-rs = { version = "0.2.0", optional = true }
bincode = "1.2.1"
rustc-demangle = "0.1.16"
cpp_demangle = "0.3.2"
Expand Down
4 changes: 2 additions & 2 deletions crates/jit/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ cfg_if::cfg_if! {
}

cfg_if::cfg_if! {
if #[cfg(all(feature = "vtune", target_os = "linux"))] {
#[path = "profiling/vtune_linux.rs"]
if #[cfg(all(feature = "vtune", target_arch = "x86_64"))] {
#[path = "profiling/vtune.rs"]
mod vtune;
} else {
#[path = "profiling/vtune_disabled.rs"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//! Adds support for profiling JIT-ed code using VTune.
//!
//! ### Build
//!
//! ```ignore
//! cargo build --features=vtune
//! ```
//! Adds support for profiling JIT-ed code using VTune. By default, VTune
//! support is built in to Wasmtime (configure with the `vtune` feature flag).
//! To enable it at runtime, use the `--vtune` CLI flag.
//!
//! ### Profile
//!
Expand Down
1 change: 1 addition & 0 deletions crates/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ default = [
'cranelift',
'pooling-allocator',
'memfd',
'vtune',
]

# An on-by-default feature enabling runtime compilation of WebAssembly modules
Expand Down
4 changes: 2 additions & 2 deletions crates/wasmtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@
//! jitdump runtime profiling format. The profiler can be selected with
//! [`Config::profiler`].
//!
//! * `vtune` - Not enabled by default, this feature compiles in support for
//! supporting VTune profiling of JIT code.
//! * `vtune` - Enabled by default, this feature compiles in support for VTune
//! profiling of JIT code.
//!
//! * `uffd` - Not enabled by default. This feature enables `userfaultfd` support
//! when using the pooling instance allocator. As handling page faults in user space
Expand Down
13 changes: 5 additions & 8 deletions docs/examples-profiling-vtune.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ For more information on VTune and the analysis tools it provides see its

### Turn on VTune support

For JIT profiling with VTune, first build with the `vtune` feature enabled:

```sh
$ cargo build --features=vtune
```

Then, enable runtime support based on how you use Wasmtime:
For JIT profiling with VTune, Wasmtime currently builds with the `vtune` feature
enabled by default. This ensures the compiled binary understands how to inform
the `ittapi` library of JIT events. But it must still be enabled at
runtime--enable runtime support based on how you use Wasmtime:
Comment on lines +35 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, it seems the end of this comment after -- would need to be removed, as it contains : but with no extra indication thereafter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's setting up the list of ways to enable VTune at runtime (if I understand what you mean).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it and we can fix it up later if we think of a more clear way to word this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, i misread it as a list entry as well, my bad. Maybe can reformulate slightly then:

Suggested change
the `ittapi` library of JIT events. But it must still be enabled at
runtime--enable runtime support based on how you use Wasmtime:
the `ittapi` library of JIT events. But it must still be enabled at
runtime with one of the following:


* **Rust API** - call the [`Config::profiler`] method with
`ProfilingStrategy::VTune` to enable profiling of your wasm modules.
Expand All @@ -62,7 +59,7 @@ future.
With VTune [properly installed][download], if you are using the CLI execute:

```sh
$ cargo build --features=vtune
$ cargo build
$ vtune -run-pass-thru=--no-altstack -collect hotspots target/debug/wasmtime --vtune foo.wasm
```

Expand Down
12 changes: 8 additions & 4 deletions docs/examples-profiling.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Profiling WebAssembly

One of WebAssembly's major goals is to be quite close to native code in terms of
performance, so typically when executing wasm you'll be quite interested in how
well your wasm module is performing! From time to time you might want to dive a
bit deeper into the performance of your wasm, and this is where profiling comes
performance, so typically when executing Wasm you'll be quite interested in how
well your Wasm module is performing! From time to time you might want to dive a
bit deeper into the performance of your Wasm, and this is where profiling comes
into the picture.

Profiling support in Wasmtime is still under development, but if you're using either [perf](./examples-profiling-perf.md) or [Vtune](./examples-profiling-vtune.md) the examples in these sections are targeted at helping you get some information about the performance of your wasm modules.
Profiling support in Wasmtime is still under development, but if you're using
either [perf](./examples-profiling-perf.md) or
[VTune](./examples-profiling-vtune.md) the examples in these sections are
targeted at helping you get some information about the performance of your Wasm
modules.