-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Link-Time Optimization (LTO) #1010
Comments
Enable Link-Time Optimization (LTO) for Rust schedulers. It improves the binary size and allows to a compiler perform more aggressive optimizations. More details in sched-ext#1010
I pretty much only run release builds for development. I think this idea makes sense in general, but it should be done with a separate profile/config on Cargo/Meson to work.
This is a good idea. |
yeah I just figured I'd stop doing this if this change were made, but a separate profile is a better idea tbh. this change as is would make ci a bit slower also. |
It makes sense for release profile to be used for.. uhm.. releases. And a dev profile can be set up for development in the necessary way. |
Not super opposed to this (nor super in support of it, the rust code isn't doing anything too heavy tbh), but we're running into bad queue'ing on GH free tier already and are a bit unsure how to deal with this (🤔), and we would want to run a build with this profile per commit on ci. Misc btw, if we're gonna add LTO, we may as well set CUs to 1 (so LTO works best), opt level to 3. |
I think there is an argument for LTO by default given we care about performance, e.g. if a random person clones |
Enable Link-Time Optimization (LTO) for Rust schedulers. It improves the binary size and allows to a compiler perform more aggressive optimizations. More details in sched-ext#1010
I opened #1155, but got stuck at a linker error. (Not experienced enough with meson to debug this, meson is probably stripping the archive index, which ld linker needs). Any help would be nice! |
Hi!
I noticed that in the build scripts 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 the application's performance. If you want to read a bit more about LTO, I can recommend starting from this Rustc documentation (similar pages exist for C compilers like GCC and Clang -
-flto
compiler switch).I suggest enabling LTO only for the Release builds so as not to sacrifice the developers' experience while working on the project since LTO consumes an additional amount of time to finish the compilation routine. If you think that a regular Release build should not be affected by such a change as well, then I suggest adding an additional
dist
orrelease-lto
profile where in addition to regularrelease
optimizations LTO will also be added. Such a change simplifies life for maintainers and others interested in the project persons who want to build the most performant version of the application. E.g., checkcargo-outdated
Release profile.Basically, it can be enabled with the following lines for the Rust part:
I have made quick tests (Fedora 41, Rustc 1.83) by adding
lto = true
to the Release profile. The binary size reduction is the following:scp_bpflang
: from 5 Mib to 3.9 Mibscx_flash
: from 4.9 Mib to 3.9 Mibscx_lavd
: from 5.3 Mib to 4.2 Mibscx_layered
: from 6 Mib to 4.7 Mibscx_loader
: from 6 Mib to 4.5 Mibscx_mitosis
: from 2.1 Mib to 1.8 Mibscx_rlfifo
: from 3.5 Mib to 2.8 Mibscx_rustland
: from 5 to 3.9 Mibscx_rusty
: from 5.5 Mib to 4.4 MibI also suggest enabling LTO for the C part of the project - didn't perform such tests though but it should work too.
We discussed a bit this topic with @arighi in Discord - I will provide a PR for the Rust part of the project with enabling LTO. Regarding the C part - I am not sure since I am not an expert in Meson.
Thank you.
The text was updated successfully, but these errors were encountered: