influxdata / influxdb

Scalable datastore for metrics, events, and real-time analytics
https://influxdata.com
Apache License 2.0
28.86k stars 3.55k forks source link

[3.x] InfluxDB v3(IOx) binary size too large #24537

Open dlgs5100 opened 10 months ago

dlgs5100 commented 10 months ago

Describe the issue I use RUSTFLAGS="-C linker=x86_64-linux-gnu-gcc" cargo build --release to build the latest InfluxDB v3 on main branch. I noticed that the generated binary size has reached an astonishing 1.7 GB. Even setting opt-level = "z" and lto = "thin" in Cargo.toml, the binary size remains 992.9 MB. It still too large in my situation.

Environment OS: x86_64 linux Toolchain: x86_64-linux-gnu-gcc

Here are my questions:

  1. Does the above build method include optional features of InfluxDB v3? How to disable it?
  2. What is the performance impact of InfluxDB v3 when using opt-level = "z" and lto = "thin"?
  3. Does InfluxDB v3 support dynamic linking instead of static linking?

By the way, I noticed that metrico/iox-community provides release binaries only 31.1 MB. This seems to be a reasonable size. Does anyone know the differences in the build process that lead to such a contrast in binary size?

alamb commented 9 months ago

This is likely because by default the binary is built with debug symbols: https://github.com/influxdata/influxdb/blob/acfef87659c9a8c4c49e4628264369569e04cad1/Cargo.toml#L142-L145

Removing the debug=true or running strip on the resulting binary will likely make is much smaller

dlgs5100 commented 9 months ago

After using strip = "symbols" and codegen-units = 1 The binary size is about 81M That helps me a lot, thank you @alamb