getsentry / symbolicator

Native Symbolication as a Service
https://getsentry.github.io/symbolicator/
MIT License
359 stars 48 forks source link

Enable LTO for release builds #1337

Closed Swatinem closed 10 months ago

Swatinem commented 10 months ago

Related to https://github.com/getsentry/symbolicator/issues/1334 CC @zamazan4ik

This is so far just doing the first step, using 1 CGU and LTO to optimize the compiler output, without relying on instrumentation and gathering profiling.

Using cargo --timings, I get local bound times of ~260s of Rust build + ~640s of linking time (LLVM does code generation at link time with LTO if I understand things correctly) for a total of ~15 minutes.

The first part we can mostly solve with dependency caching, but not the last linking step. So our docker builds will most likely take in the order of 10 minutes.

I would actually like to land this and maybe let it run over the weekend in a canary, so we can compare that to the baseline.

skip-changelog

codecov[bot] commented 10 months ago

Codecov Report

Merging #1337 (7d6b2ae) into master (8f3a697) will decrease coverage by 0.01%. The diff coverage is 100.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1337 +/- ## ========================================== - Coverage 75.67% 75.67% -0.01% ========================================== Files 99 99 Lines 14765 14767 +2 ========================================== + Hits 11174 11175 +1 - Misses 3591 3592 +1 ```
zamazan4ik commented 10 months ago

If building time is important, I can suggest a trick with creating an additional Cargo profile (let's call it profile.release-lto) and build it not per every commit but maybe per release or something like that.

Here are some examples:

Another positive outcome from enabling LTO is reduced binary size (however for Symbolicator it shouldn't be a critical advantage).

zamazan4ik commented 10 months ago

~640s of linking time

Regarding linking time. I can suggest you switch to LLD or even the Mold linker. Here are some benchmarks between Gold vs LLD vs Mold.

If you decide to use LLD and want to optimize the CI pipeline as much as possible, I can suggest recompiling LLD with PGO - the results can be found here.

zamazan4ik commented 10 months ago

@Swatinem also I can suggest enabling LTO for other Sentry projects like https://github.com/getsentry/relay