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

Support v0 mangling better #43

Closed
jrmuizel opened this issue Jul 24, 2019 · 8 comments
Closed

Support v0 mangling better #43

jrmuizel opened this issue Jul 24, 2019 · 8 comments

Comments

@jrmuizel
Copy link

Using the new mangling scheme is convenient because it gives more information about the particular monomorphization. However it seems like crate detection is broken.

RUSTFLAGS="-Z symbol-mangling-version=v0" rustup run nightly cargo bloat --release
gives

0.0%   0.7% 61.2KiB    [Unknown] <gleam[d1379dfb6ebdd7c7]::ffi_gl::Gl>::load_with::<wrench[a4e3b033c434546e]::make_window::{closure#0}
0.0%   0.7% 61.1KiB    [Unknown] <gleam[d1379dfb6ebdd7c7]::ffi_gl::Gl>::load_with::<wrench[a4e3b033c434546e]::make_window
0.0%   0.6% 52.5KiB    [Unknown] <wrench[a4e3b033c434546e]::yaml_frame_writer::YamlFrameWriter>
0.0%   0.6% 47.6KiB regex_syntax <regex_syntax[f84e6df1bfbac060]::ast::parse::ParserI<&mut regex_syntax[f84e6df1bfbac060]::ast::parse::Parser>>
0.0%   0.5% 40.2KiB    [Unknown] <webrender[58737326ba1c09f4]::display_list_flattener::DisplayListFlattener>
0.0%   0.5% 37.5KiB    [Unknown] <wrench[a4e3b033c434546e]::rawtest::RawtestHarness>
0.0%   0.5% 37.3KiB    [Unknown] <wrench[a4e3b033c434546e]::yaml_frame_reader::YamlFrameReader>
0.0%   0.4% 35.1KiB    [Unknown] wrench[a4e3b033c434546e]
0.0%   0.4% 34.7KiB    [Unknown] <webrender[58737326ba1c09f4]::render_backend::RenderBackend>
0.0%   0.4% 33.7KiB    webrender <webrender[58737326ba1c09f4]::renderer::Renderer>
@RazrFalcon
Copy link
Owner

Yes, the parser is for current version only.

@RazrFalcon
Copy link
Owner

Looks like we have to write a custom v0 parser, since it's way more complex than legacy and we can't simply split the name by ::.

This will also allow us to skip the disambiguation hashes.

But the format is quite complex and we can't use the rustc-demangle parser, because it stateless/recursive.

@RazrFalcon RazrFalcon added the help wanted Extra attention is needed label Aug 3, 2019
@jrmuizel
Copy link
Author

It looks like https://github.com/michaelwoerister/std-mangle-rs is the recommended (rust-lang/rustc-demangle#28) solution to this problem.

@RazrFalcon
Copy link
Owner

Interesting. I will try it out. The only problem is how fast it would be when we need to parse thousands of names.

@RazrFalcon
Copy link
Owner

By the way, what is the difference between v0 and v2?

@RazrFalcon
Copy link
Owner

Also, look like the std-mangle-rs crate is outdated:

> cargo run -- '_RNvMs1_NtCsgE5p2UZupUb_4json5valueNtB5_9JsonValue7is_null'
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/rust-filt _RNvMs1_NtCsgE5p2UZupUb_4json5valueNtB5_9JsonValue7is_null`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "at position 40: Expected \'C\', \'M\', \'X\', \'Y\', \'N\', \'I\', or \'B\'; found \'1\' instead; while parsing <path>"', src/libcore/result.rs:999:5

@RazrFalcon
Copy link
Owner

Done. Please test it out.

@RazrFalcon RazrFalcon removed the help wanted Extra attention is needed label Aug 14, 2019
@jrmuizel
Copy link
Author

Works great:

File  .text    Size         Crate Name
0.0%   0.7% 61.2KiB         gleam <gleam::ffi_gl::Gl>::load_with::<wrench::make_window::{closure#0}::{closure#0}>
0.0%   0.7% 61.1KiB         gleam <gleam::ffi_gl::Gl>::load_with::<wrench::make_window::{closure#1}>
0.0%   0.6% 52.5KiB        wrench <wrench::yaml_frame_writer::YamlFrameWriter>::write_display_list_items
0.0%   0.6% 47.6KiB  regex_syntax <regex_syntax::ast::parse::ParserI<&mut regex_syntax::ast::parse::Parser>>::parse_with_comments
0.0%   0.5% 40.2KiB     webrender <webrender::display_list_flattener::DisplayListFlattener>::flatten_item
0.0%   0.5% 37.5KiB        wrench <wrench::rawtest::RawtestHarness>::run
0.0%   0.5% 37.3KiB        wrench <wrench::yaml_frame_reader::YamlFrameReader>::add_display_list_items_from_yaml
0.0%   0.4% 35.1KiB        wrench wrench::main
0.0%   0.4% 34.7KiB     webrender <webrender::render_backend::RenderBackend>::process_api_msg
0.0%   0.4% 33.7KiB     webrender <webrender::renderer::Renderer>::update
0.0%   0.4% 31.3KiB     webrender <webrender::batch::BatchBuilder>::add_prim_to_batch
0.0%   0.4% 31.0KiB       inflate <inflate::InflateStream>::next_state
0.0%   0.3% 27.0KiB webrender_api <webrender_api::display_item::DebugDisplayItem as serde::ser::Serialize>::serialize::<&mut serde_json::ser::Serializer<&mut alloc::vec::Vec<u8>, serde_json::ser::PrettyFormatter>>
0.0%   0.3% 25.6KiB         winit <winit::platform::platform::x11::EventsLoop>::process_event::<&mut <winit::platform::platform::x11::EventsLoop>::run_forever<wrench::render::{closure#1}>::{closure#0}>
0.0%   0.3% 24.2KiB         image <jpeg_decoder::decoder::Decoder<std::io::buffered::BufReader<std::fs::File>>>::decode_internal
0.0%   0.3% 24.0KiB          clap <clap::app::parser::Parser>::get_matches_with::<&mut std::env::ArgsOs, std::ffi::os_str::OsString>
0.0%   0.3% 22.8KiB     webrender <webrender::renderer::Renderer>::new::{closure#2}
0.0%   0.3% 22.8KiB         gleam <gleam::ffi_gles::Gles2>::load_with::<wrench::make_window::{closure#0}::{closure#1}>
0.0%   0.3% 22.8KiB         gleam <gleam::ffi_gles::Gles2>::load_with::<wrench::make_window::{closure#2}>
0.0%   0.3% 22.5KiB         image <jpeg_decoder::decoder::Decoder<std::io::buffered::BufReader<std::fs::File>>>::decode_internal
3.4%  91.5%  7.3MiB               And 14484 smaller methods. Use -n N to show more.
3.7% 100.0%  8.0MiB               .text section size, the file size is 214.0MiB

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

No branches or pull requests

2 participants