Skip to content

Conversation

@therealprof
Copy link
Contributor

@therealprof therealprof commented Jan 9, 2025

Turns out to be another win by doing a manual insertion sort of the suggestion rather than using sort_by.

Before:

# cargo bloat --release --example git
    Finished `release` profile [optimized] target(s) in 0.05s
    Analyzing target/release/examples/git

 File  .text     Size        Crate Name
 1.6%   2.8%  15.2KiB          git git::main
 1.5%   2.7%  14.8KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 1.5%   2.6%  14.1KiB clap_builder clap_builder::builder::command::Command::_build_self
 1.0%   1.7%   9.4KiB          std std::backtrace_rs::symbolize::gimli::resolve
 0.9%   1.6%   8.6KiB          std std::backtrace_rs::symbolize::gimli::Context::new
 0.7%   1.3%   7.1KiB          std gimli::read::dwarf::Unit<R>::new
 0.7%   1.3%   7.1KiB    [Unknown] __mh_execute_header
 0.7%   1.3%   7.0KiB clap_builder <clap_builder::error::format::RichFormatter as clap_builder::error::format::ErrorFormatter>::format_error
 0.7%   1.2%   6.4KiB clap_builder clap_builder::parser::validator::Validator::validate
 0.6%   1.1%   5.9KiB          std addr2line::ResUnit<R>::find_function_or_location::{{closure}}
 0.6%   1.1%   5.9KiB clap_builder <alloc::vec::Vec<T,A> as core::clone::Clone>::clone
 0.6%   1.0%   5.4KiB clap_builder clap_builder::output::help_template::HelpTemplate::write_all_args
 0.5%   1.0%   5.2KiB clap_builder clap_builder::output::usage::Usage::write_arg_usage
 0.5%   0.9%   5.1KiB          std addr2line::Lines::parse
 0.5%   0.9%   5.1KiB clap_builder clap_builder::parser::parser::Parser::react
 0.5%   0.8%   4.5KiB clap_builder clap_builder::output::usage::Usage::write_usage_no_title
 0.5%   0.8%   4.4KiB clap_builder clap_builder::parser::parser::Parser::parse_help_subcommand
 0.4%   0.8%   4.1KiB          std addr2line::function::Function<R>::parse_children
 0.4%   0.8%   4.1KiB clap_builder clap_builder::output::help_template::HelpTemplate::write_templated_help
 0.4%   0.7%   3.9KiB          std gimli::read::unit::parse_attribute
42.6%  75.2% 408.9KiB              And 1183 smaller methods. Use -n N to show more.
56.7% 100.0% 544.0KiB              .text section size, the file size is 960.0KiB

and after:

# cargo bloat --release --example git
    Finished `release` profile [optimized] target(s) in 0.05s
    Analyzing target/release/examples/git

  File  .text     Size        Crate Name
 1.6%   2.9%  15.2KiB          git git::main
 1.6%   2.8%  14.8KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 1.5%   2.6%  14.1KiB clap_builder clap_builder::builder::command::Command::_build_self
 1.0%   1.8%   9.4KiB          std std::backtrace_rs::symbolize::gimli::resolve
 0.9%   1.6%   8.6KiB          std std::backtrace_rs::symbolize::gimli::Context::new
 0.8%   1.3%   7.1KiB          std gimli::read::dwarf::Unit<R>::new
 0.7%   1.3%   7.0KiB clap_builder <clap_builder::error::format::RichFormatter as clap_builder::error::format::ErrorFormatter>::format_error
 0.7%   1.2%   6.1KiB clap_builder clap_builder::parser::validator::Validator::validate
 0.6%   1.1%   5.9KiB          std addr2line::ResUnit<R>::find_function_or_location::{{closure}}
 0.6%   1.1%   5.9KiB clap_builder <alloc::vec::Vec<T,A> as core::clone::Clone>::clone
 0.6%   1.1%   5.8KiB    [Unknown] __mh_execute_header
 0.6%   1.0%   5.4KiB clap_builder clap_builder::output::help_template::HelpTemplate::write_all_args
 0.6%   1.0%   5.2KiB clap_builder clap_builder::output::usage::Usage::write_arg_usage
 0.5%   1.0%   5.1KiB          std addr2line::Lines::parse
 0.5%   1.0%   5.1KiB clap_builder clap_builder::parser::parser::Parser::react
 0.5%   0.8%   4.5KiB clap_builder clap_builder::output::usage::Usage::write_usage_no_title
 0.5%   0.8%   4.4KiB clap_builder clap_builder::parser::parser::Parser::parse_help_subcommand
 0.4%   0.8%   4.1KiB          std addr2line::function::Function<R>::parse_children
 0.4%   0.8%   4.1KiB clap_builder clap_builder::output::help_template::HelpTemplate::write_templated_help
 0.4%   0.7%   3.9KiB          std gimli::read::unit::parse_attribute
42.1%  74.6% 396.4KiB              And 1163 smaller methods. Use -n N to show more.
56.4% 100.0% 531.3KiB              .text section size, the file size is 942.1KiB

@epage epage enabled auto-merge January 9, 2025 17:46
auto-merge was automatically disabled January 9, 2025 17:47

Head branch was pushed to by a user without write access

@therealprof therealprof force-pushed the features/suggestions-use-insertion-sort branch from 1e0530b to f71b41c Compare January 9, 2025 17:47
@therealprof
Copy link
Contributor Author

Argh, forgot to run the unit tests on the last change which changed the order of the results in a test for some reason. Will fix or revert to previous version.

Turns out to be another win in case the suggestions feature is enabled

Signed-off-by: Daniel Egger <[email protected]>
@therealprof therealprof force-pushed the features/suggestions-use-insertion-sort branch from f71b41c to 4f448df Compare January 9, 2025 17:54
@therealprof
Copy link
Contributor Author

Okay, reverted back to previous version. Sorry about that.

@epage epage merged commit a7f6acf into clap-rs:master Jan 9, 2025
22 of 25 checks passed
@therealprof therealprof deleted the features/suggestions-use-insertion-sort branch January 9, 2025 18:10
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 this pull request may close these issues.

2 participants