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

Symbols are not demangled properly with -Csymbol-mangling-version=v0 #362

Closed
bobrik opened this issue Feb 4, 2025 · 6 comments · Fixed by #363
Closed

Symbols are not demangled properly with -Csymbol-mangling-version=v0 #362

bobrik opened this issue Feb 4, 2025 · 6 comments · Fixed by #363

Comments

@bobrik
Copy link
Contributor

bobrik commented Feb 4, 2025

See: https://doc.rust-lang.org/rustc/symbol-mangling/v0.html

With default demangling:

Image

With RUSTFLAGS=-Csymbol-mangling-version=v0:

Image

That's on macOS, so dtrace based profiling.

There's a crate that supports better demangling: https://github.com/luser/rustfilt

@bobrik
Copy link
Contributor Author

bobrik commented Feb 4, 2025

My best guess: by default dtrace does an equivalent of c++filt, which just doesn't understand v0 mangling:

$ echo 'requests-5d17f3a5c1ea5a42`_RNCNvXs0_NtCshIpxUpB4cO7_3fl29lifecycleINtB7_14FL2RequestHookNtB9_6FL2AppEINtNtNtCsirrfZNuT3Ck_7oxy_api12pub_wrappers5hooks15HttpRequestHookBX_E21handle_client_request0B9_' | c++filt
requests-5d17f3a5c1ea5a42`_RNCNvXs0_NtCshIpxUpB4cO7_3fl29lifecycleINtB7_14FL2RequestHookNtB9_6FL2AppEINtNtNtCsirrfZNuT3Ck_7oxy_api12pub_wrappers5hooks15HttpRequestHookBX_E21handle_client_request0B9_

Compare to rustfilt:

$ echo 'requests-5d17f3a5c1ea5a42`_RNCNvXs0_NtCshIpxUpB4cO7_3fl29lifecycleINtB7_14FL2RequestHookNtB9_6FL2AppEINtNtNtCsirrfZNuT3Ck_7oxy_api12pub_wrappers5hooks15HttpRequestHookBX_E21handle_client_request0B9_' | rustfilt
requests-5d17f3a5c1ea5a42`<fl2::lifecycle::FL2RequestHook<fl2::FL2App> as oxy_api::pub_wrappers::hooks::HttpRequestHook<fl2::FL2App>>::handle_client_request::{closure#0}

Outside of cargo flamegraph with perf we normally request --no-demangle and pipe through rustfilt and then c++filt for a good measure, which seems to work well. I'm not sure if c++filt is necessary, rustfilt might be sufficient.

@djc
Copy link
Contributor

djc commented Feb 4, 2025

Open to review a PR for this if it belongs in flamegraph, maybe it belongs in inferno instead?

@bobrik
Copy link
Contributor Author

bobrik commented Feb 5, 2025

I think demangling should happen before stack collapsing, so it belongs here. @jonhoo, what do you think?

@jonhoo
Copy link

jonhoo commented Feb 8, 2025

Hmm, so, inferno doesn't demangle internally — we even explicitly removed support for that ages ago in jonhoo/inferno#144. See also jonhoo/inferno#180 (comment). It generally expects that whatever tool produces the input to the stack collapser does the demangling.

@djc
Copy link
Contributor

djc commented Feb 8, 2025

Fair enough.

bobrik added a commit to bobrik/flamegraph-rs that referenced this issue Feb 10, 2025
This enables proper demangling of `RUSTFLAGS=-Csymbol-mangling-version=v0`,
especially on macOS where the binary name is included in the frames.

Closes flamegraph-rs#362.
bobrik added a commit to bobrik/flamegraph-rs that referenced this issue Feb 10, 2025
This enables proper demangling of `RUSTFLAGS=-Csymbol-mangling-version=v0`,
especially on macOS where the binary name is included in the frames.

Closes flamegraph-rs#362.
@bobrik
Copy link
Contributor Author

bobrik commented Feb 10, 2025

I opened #363 to take care of this.

@djc djc closed this as completed in #363 Feb 10, 2025
@djc djc closed this as completed in 97dcfe9 Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants