servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.29k stars 322 forks source link

URL 2.5.x 4+MB in size after optimised build. #952

Open patrickjquinn opened 1 month ago

patrickjquinn commented 1 month ago

Describe the bug The url dep represents >50% of the overall binary size when targeting MacOS (Both arm64 and universal)

Build optimisations:

[profile.release] opt-level = "z" lto = true codegen-units = 1 panic = 'abort' strip = true

Attached is the output of my "bloat" command:

File .text Size Crate 51.0% 294.2% 4.6MiB url 2.2% 12.5% 201.2KiB tauri 1.8% 10.1% 163.7KiB core 1.7% 9.6% 155.0KiB regex_automata 1.3% 7.4% 119.2KiB [Unknown] 1.2% 7.2% 116.4KiB std 1.1% 6.6% 106.1KiB tao 0.7% 4.3% 68.8KiB regex_syntax 0.7% 3.9% 63.2KiB aho_corasick 0.6% 3.7% 60.2KiB serde 0.4% 2.3% 37.2KiB alloc 0.4% 2.2% 35.9KiB tokio 0.3% 1.9% 30.5KiB wry 0.3% 1.9% 30.4KiB gimli 0.3% 1.8% 29.0KiB tauri_runtime_wry 0.3% 1.7% 27.7KiB serde_json 0.3% 1.5% 24.8KiB addr2line 0.2% 1.4% 22.1KiB infer 0.2% 1.3% 20.8KiB brotli_decompressor 0.2% 1.2% 19.6KiB tauri_utils 0.2% 1.1% 18.5KiB rustc_demangle 0.2% 1.1% 18.2KiB rodio 0.2% 1.0% 16.7KiB http 0.2% 0.9% 14.8KiB chrono 0.1% 0.8% 12.3KiB tauri_runtime 0.1% 0.5% 8.3KiB once_cell 0.1% 0.5% 8.1KiB regex 0.1% 0.4% 7.2KiB anyhow 0.1% 0.4% 7.1KiB coreaudio 0.1% 0.4% 7.1KiB miniz_oxide 0.1% 0.4% 7.0KiB hashbrown 0.1% 0.4% 6.3KiB memchr 0.1% 0.4% 6.1KiB cocoa 0.1% 0.4% 5.9KiB simple_logger 0.1% 0.3% 5.1KiB flate2 0.1% 0.3% 4.8KiB png 0.0% 0.3% 4.2KiB rfd 0.0% 0.2% 4.0KiB rand_chacha 0.0% 0.2% 3.5KiB sha2 0.0% 0.2% 3.4KiB cpal 0.0% 0.2% 3.1KiB unicode_normalization 0.0% 0.2% 3.0KiB glob 0.0% 0.2% 2.9KiB cocoa_foundation 0.0% 0.2% 2.8KiB parking_lot 0.0% 0.2% 2.8KiB crossbeam_channel 0.0% 0.2% 2.7KiB time 0.0% 0.2% 2.7KiB parking_lot_core 0.0% 0.2% 2.6KiB battery 0.0% 0.2% 2.6KiB sysinfo 0.0% 0.2% 2.5KiB fdeflate 0.0% 0.2% 2.4KiB objc 0.0% 0.1% 2.2KiB ryu 0.0% 0.1% 2.1KiB semver 0.0% 0.1% 2.1KiB cfb 0.0% 0.1% 2.1KiB ignore 0.0% 0.1% 2.1KiB bytes 0.0% 0.1% 2.0KiB colored 0.0% 0.1% 1.8KiB idna 0.0% 0.1% 1.7KiB object 0.0% 0.1% 1.2KiB core_foundation 0.0% 0.1% 1.1KiB json_patch 0.0% 0.1% 1.0KiB percent_encoding 0.0% 0.1% 1.0KiB os_info 0.0% 0.1% 992B compiler_builtins 0.0% 0.1% 916B rand 0.0% 0.1% 892B hound 0.0% 0.1% 888B dirs_next 0.0% 0.1% 848B uuid 0.0% 0.1% 836B getrandom 0.0% 0.0% 608B serialize_to_javascript 0.0% 0.0% 592B open 0.0% 0.0% 592B tinyvec 0.0% 0.0% 456B crossbeam_utils 0.0% 0.0% 452B phf_shared 0.0% 0.0% 404B byteorder 0.0% 0.0% 400B crc32fast 0.0% 0.0% 396B time_core 0.0% 0.0% 360B state 0.0% 0.0% 352B itoa 0.0% 0.0% 304B digest 0.0% 0.0% 296B smallvec 0.0% 0.0% 272B dirs_sys_next 0.0% 0.0% 232B walkdir 0.0% 0.0% 224B globset 0.0% 0.0% 220B log 0.0% 0.0% 212B simd_adler32 0.0% 0.0% 192B generic_array 0.0% 0.0% 148B rand_core 0.0% 0.0% 144B siphasher 0.0% 0.0% 140B libc 0.0% 0.0% 140B objc_foundation 0.0% 0.0% 116B objc_exception 0.0% 0.0% 104B unicode_bidi 0.0% 0.0% 56B panic_abort 0.0% 0.0% 48B same_file 0.0% 0.0% 40B core_graphics 0.0% 0.0% 40B fnv 0.0% 0.0% 12B dispatch 0.0% 0.0% 4B equivalent 0.0% 0.0% 4B malloc_buf 17.3% 100.0% 1.6MiB .text section size, the file size is 9.1MiB

Not sure if this is a regression or as expected. Also not sure if it's related to the regression here: https://github.com/servo/rust-url/issues/939

hsivonen commented 1 month ago

4.6MiB url 2.2%

That's weird. The crates with notable data are unicode-normalization and idna 0.5.0, not url itself.

Not sure if this is a regression or as expected. Also not sure if it's related to the regression here: https://github.com/servo/rust-url/issues/939

What happens to the binary size numbers if you do cargo update -p url --precise 2.5.1 ?

richarddd commented 1 month ago

I can confirm this is the case for other targets as well (such as aarch64). 2.5.2 vs. 2.5.1 is much larger

hsivonen commented 1 month ago

Is 2.5.2 much larger than 2.5.0?

(2.5.1 used icu_normalizer, which is smaller than unicode-normalization, and 2.5.2 reverted to unicode-normalization. See #937 and #939.)

richarddd commented 2 weeks ago

Is 2.5.2 much larger than 2.5.0?

(2.5.1 used icu_normalizer, which is smaller than unicode-normalization, and 2.5.2 reverted to unicode-normalization. See #937 and #939.)

@hsivonen 2.5.0 and 2.5.2 are about the same.

hsivonen commented 2 weeks ago

Thanks. Great to see that you found the characteristics of 2.5.1 preferable.