perf: reduce time-to-interactive for large git repos #109

Merged
cornservant merged 1 commit from perf/improve-time-to-interactive into nightly 2026-09-28 18:24:05 -05:00
cornservant commented 2026-09-24 06:14:17 -05:00 (Migrated from github.com)

Checklist

  • Read CONTRIBUTING.md
  • Ran tests (./scripts/test) locally
  • Formatted with Stylua
  • Added tests if necessary
  • Updated documentation(inline to source code) if applicable
  • Updated README.md if applicable

Summary

time-to-interactive: The time it takes from launching neovim until the user can perform inputs.

This PR improves the time-to-interactive when haunt.nvim is in the runtime path and particularly if the git repository in which neovim is launched is quite large.

This is achieved by replacing the command git rev-list --max-parents=0 HEAD with git rev-list -n 1 --max-parents=0 HEAD inside of the project_id_with_root() function, as only the very first result is needed.

In my checkout of the quite sizable NixOS/nixpkgs repo this improves the time-to-interactive by over 4 seconds.

$ time git rev-list --max-parents=0 HEAD
c5c4a43b0e8056328ec4529f735cabdb8f1942bb
51bad44cd8712f26a77a7b5a2581e6526ff6e1c1
4bd6934a050e4a047a470985c753b1362feaa290
e019265ec958f836b0290d07afbf5fe2e1c3d14a
2766a4b44ee6eafae03a042801270c7f6b8ed32a

real    0m4,671s
user    0m4,463s
sys     0m0,192s

$ time git rev-list -n 1 --max-parents=0 HEAD
c5c4a43b0e8056328ec4529f735cabdb8f1942bb

real    0m0,014s
user    0m0,005s
sys     0m0,009s

Ideally haunt.nvim never increases the time-to-interactive, no matter how long specific git commands take. Maybe that will be possible with the upcoming vim.async api.

## Checklist - [x] Read `CONTRIBUTING.md` - [x] Ran tests (`./scripts/test`) locally - [x] Formatted with Stylua - [x] Added tests if necessary - [x] Updated documentation(inline to source code) if applicable - [x] Updated `README.md` if applicable ## Summary *time-to-interactive*: The time it takes from launching neovim until the user can perform inputs. This PR improves the time-to-interactive when haunt.nvim is in the runtime path and particularly if the git repository in which neovim is launched is quite large. This is achieved by replacing the command `git rev-list --max-parents=0 HEAD` with `git rev-list -n 1 --max-parents=0 HEAD` inside of the `project_id_with_root()` function, as only the very first result is needed. In my checkout of the quite sizable `NixOS/nixpkgs` repo this improves the time-to-interactive by over 4 seconds. ``` $ time git rev-list --max-parents=0 HEAD c5c4a43b0e8056328ec4529f735cabdb8f1942bb 51bad44cd8712f26a77a7b5a2581e6526ff6e1c1 4bd6934a050e4a047a470985c753b1362feaa290 e019265ec958f836b0290d07afbf5fe2e1c3d14a 2766a4b44ee6eafae03a042801270c7f6b8ed32a real 0m4,671s user 0m4,463s sys 0m0,192s $ time git rev-list -n 1 --max-parents=0 HEAD c5c4a43b0e8056328ec4529f735cabdb8f1942bb real 0m0,014s user 0m0,005s sys 0m0,009s ``` Ideally haunt.nvim never increases the time-to-interactive, no matter how long specific `git` commands take. Maybe that will be possible with the upcoming `vim.async` api.
Owner

I am looking forward to vim.async! Thank you for the contribution. I will be moving this into nightly for testing and then merge into main probably this weekend

I am looking forward to `vim.async`! Thank you for the contribution. I will be moving this into nightly for testing and then merge into main probably this weekend
Owner

changes base again so PR would recalculate diff (thanks github)

changes base again so PR would recalculate diff (thanks github)
Sign in to join this conversation.
No description provided.