Stream: wasmtime

Topic: ✔ can vtune display be improved?


view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 17:50):

Hi! Using the vtune integration in our embedding, it works great! I can now see rust functions compiled to wasm and marked as [Dynamic code \o/

I had one question about the way vtune displays the information: it seems that Vtune manages to parse the fully qualified Rust function name, and extracts the last bit of this path as the short function name. This last part appears to me as pretty random (it's a hex string), and it's used as the main display everywhere (leftmost column in Bottom up tab, everywhere in flame graph, etc.). See for instance:

Screenshot-from-2022-01-12-18-46-00.png

Any idea what goes wrong here? Could it be that the name demangler doesn't properly support Rust names?

ping @Alex Crichton who would know about Rust compiler internals and this sort of things probably, and @Andrew Brown @Johnnie Birch from Intel as I might just be misusing Vtune. Thanks :smile:

view this post on Zulip Alex Crichton (Jan 12 2022 at 17:51):

what's probably going on there is that wasmtime is forwarding the mangled name to vtune raw (from the wasm file itself) and then vtune applies C++ demangling which helps a bit but isn't rust demangling

view this post on Zulip Alex Crichton (Jan 12 2022 at 17:52):

we could update wasmtime to probably forward the unmangled name to vtune instead

view this post on Zulip Alex Crichton (Jan 12 2022 at 17:53):

basically applying cpp_demangle and rust_demangle here -- https://github.com/bytecodealliance/wasmtime/blob/7454f1f3af05ff27bbe3c1392a0957ac1d4e0fab/crates/jit/src/profiling.rs#L64-L71

Standalone JIT-style runtime for WebAssembly, using Cranelift - wasmtime/profiling.rs at 7454f1f3af05ff27bbe3c1392a0957ac1d4e0fab · bytecodealliance/wasmtime

view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 17:53):

cool idea. Is a C++ demangler a no-op on an already demangled name, or would it just display Bad Stuff?

view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 17:54):

are you saying we should call them both, since we can't know what's the origin language?

view this post on Zulip fitzgen (he/him) (Jan 12 2022 at 17:54):

We would want to do something like demangle(&name).unwrap_or(&name)

view this post on Zulip fitzgen (he/him) (Jan 12 2022 at 17:55):

Benjamin Bouvier said:

are you saying we should call them both, since we can't know what's the origin language?

Yes, I think we would want to. They should bail out pretty quickly when given symbols from other languages, so it shouldn't be too much wasted work. worst case scenario, we can implement a checker that returns a language hint, if we really need to

view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 17:56):

Cool, let me try that!

view this post on Zulip Andrew Brown (Jan 12 2022 at 17:57):

(I just pinged @Johnnie Birch internally to see what he thinks)

view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 18:16):

Doing that, I get the fully qualified name as the function name displayed in Vtune, which is very workable! So calling it great enough :-) Screenshot-from-2022-01-12-19-15-53.png

view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 18:17):

will make a PR

view this post on Zulip Johnnie Birch (Jan 12 2022 at 18:20):

(deleted)

view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 18:21):

@Johnnie Birch I was using the Bottom/up view, or the flamegraph view. Weirdly, it seemed that in your picture, the main display name (leftmost column) wasn't the last part of the fully qualified name, but just the whole name. Could be platform differences? I'm on Linux, using the latest version of intel-basekit as downloaded from Intel's website.

view this post on Zulip Benjamin Bouvier (Jan 12 2022 at 18:25):

also I think the hex strings at the end appear because those are generic functions, but not sure

view this post on Zulip Johnnie Birch (Jan 12 2022 at 18:45):

@Benjamin Bouvier Well I deleted because I realized my comment was already obsolete after posting but I think what I saw was consistent with what you were showing in the leftmost column? I did also see the mangled name issue that you've confirmed has a solution now.

view this post on Zulip Notification Bot (Jan 13 2022 at 16:23):

Benjamin Bouvier has marked this topic as resolved.


Last updated: Dec 23 2024 at 13:07 UTC