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

ls: Reduce binary size of ls by removing regex crate #2781

Merged
merged 7 commits into from
Dec 22, 2021
Merged

ls: Reduce binary size of ls by removing regex crate #2781

merged 7 commits into from
Dec 22, 2021

Conversation

kimono-koans
Copy link
Contributor

Became interested in reducing the size of the ls binary after reading this: https://www.reddit.com/r/rust/comments/riqolp/whats_in_a_rust_binary/

Via 'cargo bloat', I found that the regex crate was the main culprit, and was a sub-dependency of the globset package. I was able to replace with the glob crate, as there is no need for full regex implementation in ls.

This change reduces the release binary size of ls by over 1/2.

@sylvestre
Copy link
Sponsor Contributor

terrific. would it be possible to include that in the ci ?

@kimono-koans
Copy link
Contributor Author

terrific. would it be possible to include that in the ci ?

I don't have much experience with different types of CI, but I suppose you could warn on including bloat-y crates and suggest using 'cargo bloat, tree.' Here is a sample output of 'cargo bloat --crates -p uu_ls' before I made any changes:

File .text Size Crate
14.2% 27.6% 385.6KiB std
11.2% 21.7% 303.8KiB clap
7.2% 14.0% 196.0KiB regex_syntax
6.5% 12.7% 177.1KiB regex
3.8% 7.3% 102.4KiB uu_ls
2.9% 5.7% 79.4KiB globset
2.8% 5.4% 75.1KiB aho_corasick
0.7% 1.4% 19.3KiB chrono
0.6% 1.2% 16.3KiB [Unknown]
0.5% 1.1% 14.7KiB memchr
0.5% 0.9% 12.8KiB uucore
0.4% 0.8% 11.7KiB lscolors
0.2% 0.5% 6.3KiB ansi_term
0.2% 0.3% 4.3KiB term_grid
0.1% 0.3% 3.9KiB os_display
0.1% 0.2% 2.8KiB strsim
0.1% 0.1% 1.7KiB textwrap
0.0% 0.1% 1.0KiB once_cell
0.0% 0.0% 304B number_prefix
0.0% 0.0% 256B log
0.0% 0.0% 704B And 6 more crates. Use -n N to show more.
51.3% 100.0% 1.4MiB .text section size, the file size is 2.7MiB

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.

None yet

2 participants