Repository navigation
Discard changes performance improvements - #1899
Conversation
Turns out idle callbacks behave funnily, in my testing they didn't fire unless there was user interaction (which seemed most counter-intuitive). I had to move my pointer over the window for it to fire at all.
…no way of knowing
|
@niik You should open an issue on electron/electron to get an async version of |
|
I'm gonna mark this as ready for review now just before heading out to vacation which is a bit of an unfair move and I apologize. If changes are needed on this feel free to either make them yourselves or leave this until I get back. One note for this is that I've removed the functionality to remove a previously tracked file from the index when ignoring it. There's a couple of reasons for that which I've discussed with @joshaber. One is that the way we've got this set up right now is if you discard any file named '.gitignore' we will reset the entire index which blows away any conflict metadata. It also differs from how Git itself deals with ignored files and diverging from Git is something we've learned from experience can cause a great deal of pain down the line. When talking this through with @joshaber we settled on the easy approach of not doing anything magical when ignoring files and seeing how that plays out. |
joshaber
left a comment
There was a problem hiding this comment.
I made a few changes but nothing substantive. Looks good 👍
This changes our discard changes logic from our current approach of resetting the entire index and calling
git checkoutwith a potentially too long (see #1668) argument list of files to instead carefully partially resetting the index and then usingcheckout-indexwith a set of files passed on stdin.New discard logic
We're trying to not invoke git linearly with the number of files to discard
so we're doing our discards in three conceptual steps.
moveItemToTrash
Electron's
moveItemToTrashfunction which we're using is synchronous and seems to take 20+ ms per file to run on my machine (Windows). Since we were calling this in a loop without yielding to the browser for all the files that needed to be discarded we were effectively locking the app, making it unresponsive until all those operations where executed. In a scenario like the one described in #1889 that could end up locking the app completely for a over a minute, or more.To combat this I've implemented a work queue that schedules synchronous work with a high priority across as many animation frames as needed. While an ideal solution would be an asynchronous version of
moveItemToTrashand a version of it that accepts an array of files to move to trash this will at least solve the immediate problem.Fixes #1889, #1668