-
Notifications
You must be signed in to change notification settings - Fork 258
fix: terrible git status performance in large repo #1519
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
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.
Schedule.wrap is usually there for a very good reason. I'm afraid I can't evaluate whether schedule.wrap is actually required or not, see: #1606
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.
I believe there's no need for schedule_wrap
here, because the jobs are just reading git output and putting it into the lines table. The only interaction with neovim here is if should_process
errors to the console, but log.error
properly vim.schedule
s logs to the console anyways. LGTM, pinging @cseickel.
@pynappo I'll go ahead and merge this, but here are a few things to consider if bugs appear: One reason this might have been set up this way could've been to not freeze neovim when the git work was slow. Maybe it was a bad solution to use schedule_wrap, but is there any other way to background this work? There may have been some other reason that was not recorded in comments. Be on the lookout and I would suggest finding the PR where this code was merged for an explanation. |
schedule_wrap doesn't background the work, it more or less just postpones it, while adding overhead. It runs on a single thread either way |
@33KK I think it's like a javascript await, where it just task switches which at least allows the app to remain responsive even while it is handling the long running job of reading the git response in little chunks. Not really backgrounding but a similar end result from a UX point of view. If that is why it was done, doing so in batches of 100 or 1K lines would have been a better way to handle it. Now that I am reminded, I think that is how it was originally done but someone changed it along the way. |
I believe the default behavior is "whenever is convenient".
As an example, these 2 should be the same local scheduled_function = function() vim.schedule(function() print("hello world!") end) end
-- We have created a function that when called will schedule our print statement
-- Note, nothing has happened yet, If we were to _not_ run the next line, we would never see our message
-- as it was never scheduled
scheduled_function()
-- Now we ran it, and we should see our message print to the console And local scheduled_function = vim.schedule_wrap(function() print("hello world!") end)
-- At this point, nothing has happened, we have simply received a function that will schedule our function later
scheduled_function()
-- Now we ran it, and we should see our message print to the console Probably not important but figured I would explain anyway :) |
schedule_wrap
floods the event loop with work that could've been done right away much faster here. massive improvement with my goofy git repo $HOME without a .gitignore