macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.47k stars 680 forks source link

Enable link-time optimization for Vim in MacVim CI builds #1314

Closed ychin closed 1 year ago

ychin commented 1 year ago

From local profiling, enabling LTO for Vim gives a small but measurable improvement to performance. One test that I did was to open a really large Markdown file with vim-markdown (which usually chokes at large files) installed, and measure how long that takes. With LTO turned on, usually it gives at least 4-9% performance boost, which seems significant enough to justify turning it on as we essentially get the improvement for free (I didn't see similar boosts in other benhcmarking I did though, so it depends). Slight caveat is that the binary size sees a small increase (presumably due to inlining) but it's not too much. It takes more time to build with this turned on though, so only do this in CI, for the publish builds (we don't do this for the other runs in the matrix so those runs can finish faster to provide timely feedbacks).

This doesn't change the compilation/linking options for MacVim binary itself as that doesn't seem to be where performance caps are.

ychin commented 1 year ago

On further tests, I couldn't quite find a consistent improvement with LTO, and on the tests that show them, it's pretty slight (only a couple %). Since this change seems like it would bulk up the build time from 1-2m to 15 minutes on CI, and I would need to do further changes to the Makefile to make the dependencies happy, and also the fact that LTO binaries are larger, just closing this for now. No point in needless optimization.