Skip to content

Commit bca7a90

Browse files
committed
Enable link-time optimization for Vim in MacVim CI builds
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 6-10% 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.
1 parent 6500a0c commit bca7a90

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

.github/workflows/ci-macvim.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,25 @@ jobs:
167167
run: |
168168
set -o verbose
169169
170+
if ${{ matrix.publish == true }}; then
171+
# Only do link-time optimizations for publish builds, so the other
172+
# ones can still finish quickly to give quick feedbacks.
173+
# We also want to back up the config.mk because we don't want it to
174+
# be active when we run tests and start compiling other binaries
175+
# other than just Vim.
176+
cp src/auto/config.mk src/auto/config.lto_backup.mk
177+
sed -i.bak -f ci/config.mk.lto.sed src/auto/config.mk
178+
fi
179+
170180
NPROC=$(getconf _NPROCESSORS_ONLN)
171181
echo "Building Vim with ${NPROC} cores"
172182
173183
make -C src -j${NPROC} Vim
174184
185+
if ${{ matrix.publish == true }}; then
186+
cp src/auto/config.lto_backup.mk src/auto/config.mk
187+
fi
188+
175189
# Re-generate Vim help tags, because sometimes the Vim's runtime is not
176190
# updated to have the latest tags.
177191
- name: Update Vim help tags

ci/config.mk.lto.sed

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Add link-time optimization for even better performance
2+
/^CFLAGS[[:blank:]]*=/s/$/ -flto/
3+
/^LDFLAGS[[:blank:]]*=/s/$/ -flto/

0 commit comments

Comments
 (0)