Hi!
Found the tool from the post in the Rust subreddit. Since the tool's description mentions the "minimal" word - let's try to make it a little bit more minimal ;)
I noticed that in the Cargo.toml file Link-Time Optimization (LTO) for the project is not enabled. I suggest switching it on since it will reduce the binary size (always a good thing to have) and will likely improve CPU performance a biiiiiiit due to more aggressive compiler optimizations (however, the CPU part is not important for this particular tool at all). Additionally, codegen-units = 1 (CU1) option can help too in a similar to LTO way, so I recommend to enable it as well.
I recommend enabling LTO only for Release builds so developers experience won't be affected by the increased build time. Actually, I can propose to use flags directly from this ripgrep profile (like stripping and other things).
Basically, it can be enabled with the following lines to the root Cargo.toml file:
[profile.release]
codegen-units = 1
lto = true # FatLTO - the most aggressive LTO version
<possible other options like strip = true>
I have made quick tests (Macbook M1 Pro, macOS Tahoe 26.5.2, Rust 1.97, cargo build -r build command, without and with stripping to be consistent with CI scripts) - here are the results:
- Current Release profile: 670 Kib (525 Kib stripped), clean build time: 7s
- Release + FatLTO + CU1: 568 Kib (460 Kib stripped), clean build time: 7s
Build time increase shouldn't be a problem since we enable it only for the Release profile - in this case, we would not affect the development lifecycle - especially with such low current compile times. If the proposed settings are added to the Cargo.toml file, all binaries (including GitHub Actions-built and released binaries) will be built with the new options automatically.
Thank you.
Hi!
Found the tool from the post in the Rust subreddit. Since the tool's description mentions the "minimal" word - let's try to make it a little bit more minimal ;)
I noticed that in the
Cargo.tomlfile Link-Time Optimization (LTO) for the project is not enabled. I suggest switching it on since it will reduce the binary size (always a good thing to have) and will likely improve CPU performance a biiiiiiit due to more aggressive compiler optimizations (however, the CPU part is not important for this particular tool at all). Additionally,codegen-units = 1(CU1) option can help too in a similar to LTO way, so I recommend to enable it as well.I recommend enabling LTO only for Release builds so developers experience won't be affected by the increased build time. Actually, I can propose to use flags directly from this
ripgrepprofile (like stripping and other things).Basically, it can be enabled with the following lines to the root Cargo.toml file:
I have made quick tests (Macbook M1 Pro, macOS Tahoe 26.5.2, Rust 1.97,
cargo build -rbuild command, without and with stripping to be consistent with CI scripts) - here are the results:Build time increase shouldn't be a problem since we enable it only for the Release profile - in this case, we would not affect the development lifecycle - especially with such low current compile times. If the proposed settings are added to the Cargo.toml file, all binaries (including GitHub Actions-built and released binaries) will be built with the new options automatically.
Thank you.