#cargo #space #executable #find

app cargo-bloat

Find out what takes most of the space in your executable

14 releases

0.6.4 May 13, 2019
0.6.2 Nov 20, 2018
0.5.2 Jul 31, 2018
0.2.2 Feb 18, 2018

#18 in Cargo plugins

Download history 33/week @ 2019-01-28 45/week @ 2019-02-04 42/week @ 2019-02-11 72/week @ 2019-02-18 80/week @ 2019-02-25 66/week @ 2019-03-04 81/week @ 2019-03-11 56/week @ 2019-03-18 146/week @ 2019-03-25 46/week @ 2019-04-01 48/week @ 2019-04-08 69/week @ 2019-04-15 135/week @ 2019-04-22 87/week @ 2019-04-29 160/week @ 2019-05-06

361 downloads per month

MIT license

34KB
744 lines

cargo-bloat

Find out what takes most of the space in your executable.

Inspired by google/bloaty.

Note: supports ELF (Linux, BSD) and Mach-O (macOS) platforms only.

Install

cargo install cargo-bloat

Usage

Get a list of the biggest functions in the release build:

% cargo bloat --release -n 10
Compiling ...
Analyzing target/release/cargo-bloat

 File  .text    Size        Crate Name
20.2%  86.6%  1.2MiB              [3651 Others]
 0.8%   3.2% 47.4KiB regex_syntax <regex_syntax::ast::parse::ParserI<'s, P>>::parse_with_comments
 0.4%   1.8% 25.7KiB         clap clap::app::parser::Parser::get_matches_with
 0.3%   1.5% 21.6KiB  cargo_bloat cargo_bloat::process_crate
 0.3%   1.1% 16.5KiB       goblin <goblin::mach::load_command::CommandVariant as scroll::ctx::Tr...
 0.3%   1.1% 16.0KiB         clap clap::app::help::Help::write_arg
 0.2%   1.0% 15.3KiB         clap clap::app::validator::Validator::validate_matched_args
 0.2%   1.0% 14.5KiB  cargo_bloat cargo_bloat::main
 0.2%   0.9% 13.7KiB        regex regex::exec::ExecBuilder::build
 0.2%   0.9% 12.6KiB         clap clap::app::help::Help::write_help
 0.2%   0.8% 12.2KiB         clap clap::app::usage::get_required_usage_from
23.3% 100.0%  1.4MiB              .text section size, the file size is 6.1MiB

Get a list of the biggest dependencies in the release build:

% cargo bloat --release --crates -n 10
Compiling ...
Analyzing target/release/cargo-bloat

 File  .text     Size Name
 7.0%  29.9% 437.5KiB std
 4.8%  20.5% 299.7KiB clap
 3.3%  14.1% 206.7KiB regex_syntax
 2.3%   9.8% 143.2KiB regex
 2.2%   9.4% 137.5KiB goblin
 1.6%   6.8%  99.4KiB [Unknown]
 0.7%   3.1%  45.4KiB cargo_bloat
 0.5%   2.3%  33.2KiB serde_json
 0.2%   1.0%  14.8KiB object
 0.2%   0.7%  10.2KiB rustc_demangle
23.3% 100.0%   1.4MiB .text section size, the file size is 6.1MiB

Note: numbers above are a result of guesswork. They are not 100% correct and never will be.

Get a list of the biggest functions in the release build filtered by the regexp:

% cargo bloat --release --filter '^__' -n 10
Compiling ...
Analyzing target/release/cargo-bloat

File .text   Size     Crate Name
0.0%  0.0%    82B           [10 Others]
0.0%  0.1%   976B       std __udivmodti4
0.0%  0.0%   153B       std __rust_start_panic
0.0%  0.0%   128B       std __rust_maybe_catch_panic
0.0%  0.0%   101B [Unknown] __libc_csu_init
0.0%  0.0%    67B [Unknown] __pthread_atfork
0.0%  0.0%    45B       std __rust_probestack
0.0%  0.0%    45B       std __rde_alloc_zeroed
0.0%  0.0%    45B       std __rde_dealloc
0.0%  0.0%    45B       std __rde_alloc
0.0%  0.0%    40B       std __rde_realloc
0.0%  0.1% 1.7KiB           filtered data size, the file size is 6.1MiB

Flags specific for the cargo-bloat:

        --crates                   Per crate bloatedness
        --filter <CRATE|REGEXP>    Filter functions by crate
        --split-std                Split the 'std' crate to original crates like core, alloc, etc.
        --full-fn                  Print full function name with hash values
    -n <NUM>                       Number of lines to show, 0 to show all [default: 20]
    -w, --wide                     Do not trim long function names

License

cargo-bloat is licensed under the MIT.

Dependencies

~7MB
~125K SLoC