-
Notifications
You must be signed in to change notification settings - Fork 153
Add a collector
command to examine and compare binary size statistics
#1772
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
Conversation
d0ae7f5
to
a7df54b
Compare
Hm, can you say more about how you chose the elf crate? I personally usually use object (https://docs.rs/object/latest/object/) -- it's also used in std, so to some extent is more maintained. It would probably make it easier to run this tool on non-ELF platforms (e.g., macOS or Windows) as well. |
Googled "Rust ELF" and selected the first thing that looked maintained, documented and allowed me to solve what I needed :) Happy to switch to |
.sos should definitely work (they're also ELF). .rlib may require https://docs.rs/ar/latest/ar/ or so - they're unix archives under the hood containing (usually) a pile of .o files (ELF or Mach-O or etc depending on platform) + the metadata. |
Yeah, this PR already uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broadly though this looks great to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks! I don't have any opinions about which ELF crate to use.
I pushed a change that just switches from |
This PR adds a new
collector
command calledbinary_stats
, which can be used to analyze the sizes of ELF binaries and libraries produced by compile benchmarks. The command could be easily modified in the future to allow analyzing arbitrary binary artifacts specified by a filesystem path.The command uses the
elf
crate to print the sizes of sections and symbols in the ELF artifact. A few heuristics are used to normalize and group section/symbol names for less output clutter.The command can also be used to compare the binary size of a benchmark between two different versions of
rustc
(this will probably be the most common use-case) and to compare the binary size between two different codegen backends (currently Llvm/Cranelift).Examples: