-
Notifications
You must be signed in to change notification settings - Fork 471
[bazel] cross language LTO #32368
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
base: main
Are you sure you want to change the base?
[bazel] cross language LTO #32368
Conversation
fix build settings
98d84e0
to
0387947
Compare
To confirm some C functions actually got inlined I checked the symbols in the final binaries
This PR
Symbols missing from the x-lang LTO version (and thus evidenced as inlined) are:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great; thank you!
I've seen this show up a bunch, every time we compare two decimals, we first have to normalize, which, if I'm not mistaken, includes a call to rescale. |
Great! Hopefully this will be a nice performance win then. I kicked off the Nightlies to see if we get any benchmark improvements |
This PR enables cross language LTO for our release builds, meaning function calls from external C dependencies like
libdecimal
can potentially get inlined into Rust code.The way this works is when building our final binaries, e.g.
environmentd
andclusterd
, we specify the-Clinker-plugin-lto
flag torustc
which has our linker (lld
) run the LTO passes instead ofrustc
. At which point all of our Rust and C code has been compiled to LLVM bitcode so tolld
is free to optimize across languages.This only works when building for Linux. Arguments that
rustc
passes to the linker when targetting macOS don't seem to be supported byld64.lld
? See rust-lang/rust#60059 for some more investigation.Motivation
Faster runtime performance.
Tips for reviewer
The commits are broken down as follows:
rustc
flags. Theoretically something like this could be upstreamed intorules_rust
which I started working on in feat: cross language LTO bazelbuild/rules_rust#3162. But for now updating cargo-gazelle is a lot easier.bin/bazel gen
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.