-
-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vimPlugins.nvim-treesitter: collate grammars #319233
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I rebuild my system with this patch and it seems to work correctly so far.
I wonder what's the trade-off between copying the files into a new store path (less individual runtime dependencies, duplication of files in the store) versus symlinking from the new store path to the existing ones (avoids duplication of files in the store, keeps all individual store paths as runtime dependencies). The startup time should be the same in both cases, I guess, assuming that resolving the symlinks is very cheap. |
d688820
to
54f33c5
Compare
It wasn't my intention to change this, good catch. Considering
There's no measurable performance impact, as far as I can tell. I've changed nixpkgs/pkgs/applications/editors/neovim/utils.nix Lines 221 to 230 in 2b32fd6
|
@stephen-huan if there are 0 rebuilds, how does it change anything? |
@PerchunPak it changes the directory structure which causes rebuilds. I don't know how ofborg determines the number of rebuilds, but it isn't accurate here. |
@stephen-huan I also manually rebuilt
|
@PerchunPak The outer derivation is the same since the plugin is the same. Instead, compare See my personal configuration. You can check that it's different when built end-to-end by See also the package tests nixpkgs/pkgs/applications/editors/vim/plugins/nvim-treesitter/overrides.nix Lines 70 to 93 in 54f33c5
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, sorry for my confusion and laziness in reading the code. If you use passthru
, that explains why there are no rebuilds (passthru
doesn't affect the out hash by design).
By just rebuilding my system using this PR, my startup time decreased from 100ms to 70-80ms.
LGTM! CC @teto
@PerchunPak a bit late, but thanks for the review and no worries about the confusion! |
Unfortunately, this change causes my neovim to not detect any grammars. Both my treesitter configuration, but also By that I mean that Once I have time, I will investigate further. |
Hey @PerchunPak, unfortunately, using I am currently on the move with limited time, so I will probably only get around to investigate properly and open an issue next week. |
I don't think it's possible to merge all the parsers into one plugin unless we change how vim plugin dependencies work in nixpkgs. Here is the reasoning behind when I initially split the different grammars into separate plugins: #201548, and for the same reason this PR breaks my (and probably @obreitwi 's as well) |
Welcome back! Yeah, you are right, this PR caused many headaches for me, so I am giving up and just opening a revert PR |
This reverts PR NixOS#319233. It caused a lot of weird regressions and a lot of headaches for me. Even a 20% improvement isn't worth it. Also see NixOS#319233 (comment)
A NixOS#319233 accidentally reverted NixOS#321550. Last one caused a very annoying regression to any Nix user (see NixOS#332580). I suppose this is a bug in upstream grammar, so I workaround it this way until it is properly resolved.
Description of changes
Currently
pkgs.vimPlugins.nvim-treesitter.withAllGrammars
adds 279 directories to'runtimepath'
, significantly slowing down startup time. See:help nvim-treesitter-performance
.This PR changes the directory structure from
vimplugin-treesitter-${grammar}/parser/${name}.so
for each grammar to a single directory of the formvimplugin-treesitter-grammars/parser/*.so
containing all specified grammars.In my configuration, this saves about 100 ms. I use
vim.loader.enable()
and the contents oftest.py
arepkgs.vimPlugins.nvim-treesitter.withPlugins (_: [ ])
(0 additional grammars)nvim --startuptime time.txt
-> ~110 msnvim --startuptime time.txt test.py
-> ~200 msnvim --startuptime time.txt
-> ~130 msnvim --startuptime time.txt test.py
-> ~220 mspkgs.vimPlugins.nvim-treesitter.withAllGrammars
(279 grammars)nvim --startuptime time.txt
-> ~200 msnvim --startuptime time.txt test.py
-> ~300 msnvim --startuptime time.txt
-> ~115 msnvim --startuptime time.txt test.py
-> ~200 mspkgs.vimPlugins.nvim-treesitter.withAllGrammars
nvim --startuptime time.txt
-> ~115 msnvim --startuptime time.txt test.py
-> ~200 msWe can conclude the cost of adding each grammar to
'runtimepath'
is linear and roughly 0.36 ms per grammar. After collating, the startup cost is negligible even with all grammars added.Ran
nix build .#vimPlugins.nvim-treesitter.tests.check-queries
andnixpkgs-review rev HEAD
.Also (a variant of this PR in my personal configuration) passes
:checkhealth
.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.