aliquote.org

July 21, 2025

Still wasting time looking at possible micro-optimizations on the CLI side. The MacBook M4 Pro is a beast, and I found it reduced by a fair amount (~ 40%) Neovim startup time. Digging into how fast it starts now (using vim-startuptime and hyperfine), I found the following:

scratch master* 2m44s
» hyperfine "nvim --headless +qa" --warmup 5

Benchmark 1: nvim --headless +qa
  Time (mean ± σ):      32.5 ms ±   0.4 ms    [User: 19.0 ms, System: 7.1 ms]
  Range (min … max):    31.4 ms …  33.7 ms    85 runs

scratch master*
» vim-startuptime --vimpath nvim
Extra options: []
Measured: 10 times

Total Average: 22.782900 msec
Total Max:     28.338000 msec
Total Min:     21.359000 msec

  AVERAGE       MAX       MIN
------------------------------
14.312000 18.240000 13.348000: /Users/chl/.config/nvim/init.lua
 5.226100  6.687000  4.827000: require('fzf-lua')
 2.576100  3.206000  2.425000: require('nvim-treesitter.configs')
 2.393600  2.972000  2.255000: require('nvim-treesitter.query')
 2.110400  2.705000  1.979000: require('vim.lsp')
 1.709600  2.168000  1.511000: require('fzf-lua.config')
 1.443200  1.824000  1.330000: require('fzf-lua.path')
 1.227300  1.388000  1.181000: loading rtp plugins
 1.133800  1.385000  1.052000: require('nvim-treesitter.tsrange')
 1.064300  1.333000  1.004000: require('nvim-treesitter.compat')
 1.053900  1.290000  0.977000: require('nvim-treesitter.ts_utils')
 1.016600  1.270000  0.961000: require('vim.treesitter')
 0.990800  1.184000  0.943000: /Users/chl/.config/nvim/plugin/lisp.lua
 0.973200  1.165000  0.927000: nvim_exec2() called at /Users/chl/.config/nvim/plugin/lisp.lua:0

The lisp.lua custom plugin is just here to load slimv which sits as an optional plugin, and so I realized that there was no gain in this case. Better to leave it as a start plugin and remove the custom plugin itself. It makes no difference whatsoever. It’s still much higher than three years ago when I was using a proper package manager and much less Lua code in my init.lua. However, I found that using vim.loader.enable() introduced in Neovim 0.9 resulted in a slight improvement:

~/.config/nvim
» hyperfine "nvim --headless +qa" --warmup 5
Benchmark 1: nvim --headless +qa
  Time (mean ± σ):      25.7 ms ±   0.5 ms    [User: 12.8 ms, System: 6.7 ms]
  Range (min … max):    24.3 ms …  26.9 ms    112 runs

Loading my init.lua is now two times faster as reported by vim-startuptime. #vim