Closed fzyzcjy closed 2 years ago
You're saying that your library is about 10MB, but cargo bloat reports 167.8MiB
. Are you sure you want to analyze vision_utils_rs
and not other library?
@RazrFalcon Hi thanks for the quick reply!
167MB is because it contains debug symbol (because bloaty does not work without debug symbols IMHO). But for end users they get a 10MB .so file without debug symbols
end users they get a 10MB .so file
But cargo bloat analyzes vision_utils_rs
, not vision_utils_rs.so
Are you 100% sure you're comparing the exactly the same file?
Nice catch! vision_utils_rs
is the executable (from main.rs) but libvision_utils_rs.so
(notice lib and so) is the library (from lib.rs I guess) that is to be used. I will analyze the so now.
Now it sounds better, thank you!
[11:58:47]: $ cargo ndk --target armeabi-v7a -- bloat --release --crates --lib -n 1000
[11:58:47]: ▸ [2022-02-02T03:58:47Z INFO cargo_ndk::cli] Using NDK at path: /Users/tom/Library/Android/sdk/ndk/21.2.6472646
[11:58:47]: ▸ [2022-02-02T03:58:47Z INFO cargo_ndk::cli] NDK API level: 21
[11:58:47]: ▸ [2022-02-02T03:58:47Z INFO cargo_ndk::cli] Building targets: armeabi-v7a
[11:58:47]: ▸ [2022-02-02T03:58:47Z INFO cargo_ndk::cli] Building armeabi-v7a (armv7-linux-androideabi)
[11:58:49]: ▸ Finished release [optimized + debuginfo] target(s) in 1.25s
[11:58:49]: ▸ Analyzing target/armv7-linux-androideabi/release/libvision_utils_rs.so
[11:58:49]: ▸ File .text Size Crate
[11:58:49]: ▸ 1.0% 33.4% 1.8MiB [Unknown]
[11:58:49]: ▸ 0.3% 11.2% 628.4KiB std
[11:58:49]: ▸ 0.2% 7.8% 436.2KiB reqwest
[11:58:49]: ▸ 0.2% 7.0% 389.5KiB protobuf
[11:58:49]: ▸ 0.1% 3.1% 174.6KiB rustls
[11:58:49]: ▸ 0.1% 3.1% 171.6KiB vision_utils_rs
[11:58:49]: ▸ 0.1% 2.8% 157.8KiB ndarray
[11:58:49]: ▸ 0.1% 2.4% 135.9KiB h2
[11:58:49]: ▸ 0.1% 2.4% 134.9KiB sentry
[11:58:49]: ▸ 0.1% 2.3% 130.5KiB regex
[11:58:49]: ▸ 0.1% 2.1% 120.4KiB ring
[11:58:49]: ▸ 0.1% 2.1% 119.5KiB regex_syntax
[11:58:49]: ▸ 0.1% 1.7% 95.2KiB tokio
[11:58:49]: ▸ 0.0% 1.5% 86.6KiB sentry_core
[11:58:49]: ▸ 0.0% 1.5% 82.4KiB hyper
[11:58:49]: ▸ 0.0% 1.1% 63.0KiB backtrace
[11:58:49]: ▸ 0.0% 1.0% 55.6KiB hashbrown
[11:58:49]: ▸ 0.0% 0.9% 49.0KiB flutter_rust_bridge
[11:58:49]: ▸ 0.0% 0.8% 45.4KiB png
[11:58:49]: ▸ 0.0% 0.7% 40.9KiB rayon_core
[11:58:49]: ▸ 0.0% 0.7% 39.1KiB deflate
[11:58:49]: ▸ 0.0% 0.7% 37.7KiB rustc_demangle
[11:58:49]: ▸ 0.0% 0.6% 35.3KiB http
[11:58:49]: ▸ 0.0% 0.6% 34.7KiB opencv
[11:58:49]: ▸ 0.0% 0.6% 34.0KiB url
[11:58:49]: ▸ 0.0% 0.5% 25.6KiB image
[11:58:49]: ▸ 0.0% 0.4% 24.5KiB encoding_rs
[11:58:49]: ▸ 0.0% 0.4% 23.5KiB threadpool
[11:58:49]: ▸ 0.0% 0.4% 22.7KiB idna
[11:58:49]: ▸ 0.0% 0.4% 22.5KiB gimli
[11:58:49]: ▸ 0.0% 0.3% 18.7KiB sentry_backtrace
[11:58:49]: ▸ 0.0% 0.3% 18.2KiB aho_corasick
[11:58:49]: ▸ 0.0% 0.3% 16.4KiB anyhow
[11:58:49]: ▸ 0.0% 0.3% 15.8KiB rayon
[11:58:49]: ▸ 0.0% 0.3% 15.5KiB chrono
[11:58:49]: ▸ 0.0% 0.3% 15.5KiB miniz_oxide
[11:58:49]: ▸ 0.0% 0.3% 14.6KiB addr2line
[11:58:49]: ▸ 0.0% 0.3% 14.0KiB sentry_types
[11:58:49]: ▸ 0.0% 0.2% 12.2KiB sentry_contexts
[11:58:49]: ▸ 0.0% 0.2% 10.3KiB sentry_anyhow
[11:58:49]: ▸ 0.0% 0.2% 10.1KiB simplelog
[11:58:49]: ▸ 0.0% 0.2% 9.0KiB webpki
[11:58:49]: ▸ 0.0% 0.2% 8.7KiB delaunator
[11:58:49]: ▸ 0.0% 0.2% 8.5KiB sentry_panic
[11:58:49]: ▸ 0.0% 0.1% 8.0KiB parking_lot
[11:58:49]: ▸ 0.0% 0.1% 7.0KiB sentry_debug_images
[11:58:49]: ▸ 0.0% 0.1% 6.5KiB ryu
[11:58:49]: ▸ 0.0% 0.1% 4.8KiB memchr
[11:58:49]: ▸ 0.0% 0.1% 4.7KiB crossbeam_epoch
[11:58:49]: ▸ 0.0% 0.1% 4.4KiB httpdate
[11:58:49]: ▸ 0.0% 0.1% 4.0KiB bytes
[11:58:49]: ▸ 0.0% 0.1% 3.9KiB encoding
[11:58:49]: ▸ 0.0% 0.1% 3.9KiB indexmap
[11:58:49]: ▸ 0.0% 0.1% 3.5KiB ipnet
[11:58:49]: ▸ 0.0% 0.1% 3.2KiB mime
[11:58:49]: ▸ 0.0% 0.1% 3.2KiB tflite_rust
[11:58:49]: ▸ 0.0% 0.1% 3.0KiB tracing_core
[11:58:49]: ▸ 0.0% 0.1% 3.0KiB android_logger
[11:58:49]: ▸ 0.0% 0.0% 2.5KiB crossbeam_channel
[11:58:49]: ▸ 0.0% 0.0% 2.3KiB termcolor
[11:58:49]: ▸ 0.0% 0.0% 2.3KiB mio
[11:58:49]: ▸ 0.0% 0.0% 1.9KiB parking_lot_core
[11:58:49]: ▸ 0.0% 0.0% 1.9KiB httparse
[11:58:49]: ▸ 0.0% 0.0% 1.7KiB serde_json
[11:58:49]: ▸ 0.0% 0.0% 1.7KiB sct
[11:58:49]: ▸ 0.0% 0.0% 1.7KiB ndarray_stats
[11:58:49]: ▸ 0.0% 0.0% 1.6KiB findshlibs
[11:58:49]: ▸ 0.0% 0.0% 1.6KiB tracing
[11:58:49]: ▸ 0.0% 0.0% 1.5KiB unicode_normalization
[11:58:49]: ▸ 0.0% 0.0% 1.5KiB rand
[11:58:49]: ▸ 0.0% 0.0% 1.5KiB percent_encoding
[11:58:49]: ▸ 0.0% 0.0% 1.4KiB allo_isolate
[11:58:49]: ▸ 0.0% 0.0% 1.4KiB getrandom
[11:58:49]: ▸ 0.0% 0.0% 1.4KiB tokio_util
[11:58:49]: ▸ 0.0% 0.0% 1.3KiB base64
[11:58:49]: ▸ 0.0% 0.0% 1.2KiB tokio_rustls
[11:58:49]: ▸ 0.0% 0.0% 1.2KiB adler
[11:58:49]: ▸ 0.0% 0.0% 1.2KiB uuid
[11:58:49]: ▸ 0.0% 0.0% 1.1KiB crc32fast
[11:58:49]: ▸ 0.0% 0.0% 1.1KiB socket2
[11:58:49]: ▸ 0.0% 0.0% 996B crossbeam_deque
[11:58:49]: ▸ 0.0% 0.0% 936B jpeg_decoder
[11:58:49]: ▸ 0.0% 0.0% 788B once_cell
[11:58:49]: ▸ 0.0% 0.0% 752B debugid
[11:58:49]: ▸ 0.0% 0.0% 752B log
[11:58:49]: ▸ 0.0% 0.0% 744B adler32
[11:58:49]: ▸ 0.0% 0.0% 726B want
[11:58:49]: ▸ 0.0% 0.0% 678B uname
[11:58:49]: ▸ 0.0% 0.0% 578B pathfinding
[11:58:49]: ▸ 0.0% 0.0% 536B itertools
[11:58:49]: ▸ 0.0% 0.0% 510B env_logger
[11:58:49]: ▸ 0.0% 0.0% 344B time
[11:58:49]: ▸ 0.0% 0.0% 280B futures_core
[11:58:49]: ▸ 0.0% 0.0% 272B futures_util
[11:58:49]: ▸ 0.0% 0.0% 214B hostname
[11:58:49]: ▸ 0.0% 0.0% 196B object
[11:58:49]: ▸ 0.0% 0.0% 188B rand_chacha
[11:58:49]: ▸ 0.0% 0.0% 164B rand_core
[11:58:49]: ▸ 0.0% 0.0% 110B smallvec
[11:58:49]: ▸ 0.0% 0.0% 104B hex
[11:58:49]: ▸ 0.0% 0.0% 96B unicode_bidi
[11:58:49]: ▸ 0.0% 0.0% 74B futures_channel
[11:58:49]: ▸ 0.0% 0.0% 34B untrusted
[11:58:49]: ▸ 0.0% 0.0% 26B ppv_lite86
[11:58:49]: ▸ 0.0% 0.0% 26B futures_task
[11:58:49]: ▸ 0.0% 0.0% 24B spin
[11:58:49]: ▸ 0.0% 0.0% 16B num_cpus
[11:58:49]: ▸ 3.0% 100.0% 5.5MiB .text section size, the file size is 182.4MiB
[11:58:49]: ▸ Note: numbers above are a result of guesswork. They are not 100% correct and never will be.
Hi thanks for the lib! However, Cargo bloaty reports only a tiny portion of the whole binary.
My
.so
file for android is about 10MB (not zipped, stripped). It contains some pure Rust code, especially using ndarray crate so I guess that take up some space. It also links to OpenCV (a C++ library) using theopencv
crate, so I guess that also takes up some space.However, when I run cargo bloaty it only reports <1MB:
Here is another attempt:
The text section should not be as small as 0.25MB. Indeed, when I run (naive) bloaty on the resulting
.so
file (that is to be packaged into android app), it says about 5MB:More info:
Could you please give some hint on where I should do? Thanks!