-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Performance problems on large repos #13
Comments
Yep the vim-test test detection is horrifically slow. It should however only trigger if an open buffer registers as a possible test file so if you're not actually using it for that repo I'd suggest disabling it for whatever filetype is causing it to run (this is just a workaround for this particular case) On to the broader issue
I actually originally wrote the adapter interface to work this way but switched to the current way to avoid running multiple crawls but now the initial detection of tests (project root detection, open buffers etc) is smarter.
I can see this being a pretty popular request not for performance but as you say for the per-project runner/settings. I think it's inevitable something will need handle this. The proposed interface looks pretty good AFAICT, though the adapters I've written (and I imagine others) would need to be refactored to handle configuring multiple instances. Wouldn't be too much work though. I think the project/discovery configuration would solve this issue better than having adapters controlling the search as it solves other issues too so for now I'll say let's go with that. This will be a rather large change so it'll take some time to work on. I think I'd like to take a stab at it myself just to get a grasp of the implementation details. I can provide more thoughts on interface as I put some more thought into it.
Love to hear that, thanks! To be honest I haven't thought about it much. I don't mind using issues right now but do feel it could get a bit noisy quickly depending on traffic. I've not used GitHub discussions much so I can take a look at that. Open to other suggestions as well! I'm planning on setting up a neotest org to keep all the repos under so I can add it to the admin TODOs 😅 |
Oh this would be excellent! That might solve another issue I've been having with multiple directories open in the same vim. If both dirs use the same test adapter, I see "Common root not found" errors. But if each dir were using a different adapter instance that might be one way around it.
Sounds good! LMK if I can help at any point. |
As far as I remember this is actually a bit of laziness on my part because I don't open multiple projects in one NeoVim instance. The trees just need to be merged inside of a new parent here https://github.com/rcarriga/neotest/blob/master/lua/neotest/lib/positions/init.lua#L84. The way the new file detection works, it shouldn't (could be wrong) scan the new parent directories. However I do prefer the idea of having separately maintained trees for each project as it'll present a lot cleaner IMO |
Finally got around to implementing per-project configs 😅 I've got it in #100 just for testing but it seems to work nicely AFAICT. If anyone runs in to issues please let me know! |
Awesome!! I'll test it out when I get a chance and leave feedback |
I'm also having lags on bigger repos. This is especially annoying during EDIT: I had wrong config setup 🤦🏻 all good. |
Separate to the project config work, I've done some benchmarking and found an easy optimisation within the treesitter internal code. I've implemented it in the the latest master and I'm seeing a 30% reduction in time to parse the cpython repo 😁 It should hopefully improve performance for most languages. This won't solve all performance issues but it will hopefully improve things a bit. I'm also planning on creating a consumer that can run benchmarks easily so others can see what is affecting performance |
OK I've added two new config options to help with discovery performance.
In terms of user experience, directory filtering is preferred over limiting concurrency which is preferred over disabling discovery altogether. I believe that these features are sufficient to tackle nearly all performance related issues. Would love to hear feedback on these! 😄 If you are still experiencing performance issues and you've disabled concurrency and set up filtering to at least rule out scanning directories like |
I tried adding the require("neotest").setup_project(vim.loop.cwd(), {
adapters = {
require("neotest-elixir")({ extra_formatters = { "ExUnit.CLIFormatter", "ExUnitNotifier" } }),
},
discovery = {
enabled = true,
filter_dir = function(name, rel_path, root)
print(name, rel_path, root)
return false
end,
},
}) I see no messages and no directory is filtered. Also, in Elixir all tests belong in a Would be possible to for an adapter to set a default |
Yep definitely think this is needed 👍 Adapters can now define a
Everything looks correct. Can you enable debug logging and submit a separate issue? |
No need, I have the Works great, thank you. |
I've not heard further reports on performance issues so I'm not sure how prevalent they are anymore but I wanted to have a little fun with using Neovim's RPC API. I've implemented the treesitter parsing to be run in a separate Neovim instance so that the only cost on the main editor instance is deserialising results. It's sitting in a PR right now #119, it'd be great to get some feedback on it. It should never expose any errors directly to the user, instead logging errors and falling back to the current in-process parsing, so when testing please check the logs (I'd recommend the Also some adapters (neotest-elixir, neotest-go, neotest-dotnet, neotest-rspec, neotest-phpunit) use callback functions for the parsing which can't be done over RPC. The solution here is to provide a string to evaluate to a function in the child process (e.g. If testing goes well, it might be possible to expose more helpers to run CPU intensive work in the subprocess |
I made the change, and it seems to be working well, although I didn't notice any change in the time it takes to discover. What I did notice is that discovery is triggered twice. When I open the summary, it outputs:
And then prints a bunch of Then, I can see the Any file I searched in the log appeared twice, and I removed the log between runs. Is there a reason for that? |
Thanks for testing it out! I don't think that'd be related to these changes as there's no change in the discovery logic, this is purely in the treesitter library functions. Are the second log lines from the parent or child instance (has Edit: Also to clarify, this won't speed up discovery (it's doing the same work), it just shouldn't ever block the editor because it's running in a separate neovim process |
Yeah, I didn't think it was related to these changes, but it is related to performance.
They are all from the parent instance.
I would either open the summary and check the logs, or run a test file and check the logs. I forgot to mention that the lines |
Thanks for the info! Could you provide a clean log for some repo that I can access? |
Sure. One more thing I noticed is that the duplicate discovering only happens when I open the summary while having a test file loaded in a buffer. If I don't have a test file open, it only prints each file once. Here is a repo I use for testing. It has very few test files, so the log is not long. parquex_info.log In the log at INFO level it is easier to notice the duplicates, but the DEBUG one provides more info, so I included both. |
Previously found adapters shouldn't have their discovery run twice on startup. See #13
Ah thanks!
This was the key 😅 It was an existing issue that has been fixed in master |
Great! The difference is very noticeable in my work repo. |
Great to hear! I'm going to merge the PR so feel free to make the change to neotest-elixir, I'll get around to submitting PRs to other adapters soon as well. |
Neotest core enabled treesitter parsing to be performed in a separate Neovim instance which means that we won't perform blocking CPU intensive work anymore. More details can be found here nvim-neotest/neotest#13 (comment). The issue is that the latest changes for building positions uses state by mutating the passed in tables to track parameterized tests, which prevents the subprocess parsing being used. Refactoring to use something stateless parsing as discussed here nvim-neotest/neotest#24 (reply in thread) allows us to use the subprocess
Enables subprocess parsing. Details here nvim-neotest/neotest#13 (comment)
Enables subprocess parsing. See nvim-neotest/neotest#13 (comment)
Enables subprocess parsing. See nvim-neotest/neotest#13 (comment)
Enables subprocess parsing. See nvim-neotest/neotest#13 (comment)
I'm going to close this issue as all of the originally requested features/changes have been made or have alternatives in place. If there are still performance issues, then we can address them specifically in separate issues. |
Thanks for the pull requests on the adapters. It definitely feels faster. ❤️ |
Enables subprocess parsing. See nvim-neotest/neotest#13 (comment)
Fantastic, love to get the feedback 😁 |
When I try to open the summary on a test file in a repo at work, nvim freezes for a very long time.
The issue is this line:
https://github.com/rcarriga/neotest/blob/aaf2107a0d639935032d60c49a5bdda2de26b4d6/lua/neotest/client/init.lua#L408
The find_files actually completes within ~2 seconds, but then running
adapter.is_test_file
250k+ times takes several minutes (vim-test adapter). After that freeze, there is a second freeze while it tries to write all the events to the logfile (hasn't finished yet).My personal opinion, test discovery should be definitely optional, and possibly configurable. My previous job had a monorepo that was so big it was only served as a virtual filesystem, so running any type of crawling operation would have terrible side effects. Making it configurable (e.g. only these dirs, only this depth) might be nice, but would probably make more sense per-adapter instead of globally. If adapters need to control the search path, their API would have to change from testing individual files that neotest gives them to calling back into neotest with whatever their search config is. IDK if that refactor is worth it, which is why I could go either way on making the search configurable.
Another direction could be to customize the search on a per-directory basis instead of per-adapter. That avoids the need for an adapter API refactor, and in general this kind of functionality would be incredibly useful. I often work with many different types of repos on the same machine, sometimes in the same vim instance (using
:tcd
and one tab per project), and these projects will sometimes use the same language but require different configurations to run tests. I'd love to be able to configure my test adapters on a per-project basis. A rough proposal, it could look like:I am happy to submit a PR for any parts of this once we align on a solution
Unrelated question: I'll probably be making more proposals, requests, and questions. Is filing an issue the best way to start a discussion, or would you prefer some other channel?
The text was updated successfully, but these errors were encountered: