wwood / CoverM

Read coverage calculator for metagenomics
GNU General Public License v3.0
273 stars 30 forks source link

Request: Strip binary and/or LTO #129

Closed jakobnissen closed 1 year ago

jakobnissen commented 1 year ago

Newer versions of cargo allows symbols to automatically be stripped from the binary in release mode. Simply add the following to your Cargo.toml

[profile.release]
strip = true

This approximately halves the size of the binary on my computer, which makes it more attractive to ship CoverM e.g. as a dependency. The downside is that stack traces will become useless. But I'm guessing the fraction of your users who know how to enable stack traces in Rust to debug an internal CoverM problem is miniscule. And among those who would know, they probably also know to just compile in debug mode if they want to debug. The quality of error messages on panics are unaffected, so since stack traces are disabled by default in Rust, the user should not see a difference.

You can also add lto = true under the [profile.release] section to enable link-time optimisation. This both improve binary size and might also improve performance (i.e .speed) of CoverM, but at the cost of longer compile times. However, on my laptop CoverM compiled in like 3 minutes in release mode with lto enabled, so it's probably worth it.

Both optimisations cut the binary size on my computer from 9.9M -> 4.7M

wwood commented 1 year ago

Indeed. Good suggestions - thanks.