microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.51k stars 29.39k forks source link

Fallback on "legacy" diff algorithm if "advanced" is too slow #216953

Open u1735067 opened 4 months ago

u1735067 commented 4 months ago

When diffing docker build logs, I noticed the new default "advanced" diff algorithm is very slow and sometimes can completely fail to produce a diff (even after 30 secs, for 15k lines file). If there's no time limit, VS code will simply hang and never produce the diff. If there's a time limit and the diff takes longer, in the end you have the 2 files side by side but with no diff. And if you set the "legacy" diff algorithm, well you can't benefit from the "advanced" one for when it works.

So, if the "advanced" algorithm fails, is to possible to fallback to the "legacy" one instead of only showing 2 files side by side? Maybe optionally, and with still a fallback to 2 files side by side if the "legacy" fails too.

This was observed on:

Version: 1.90.2 (user setup)
Commit: 5437499feb04f7a586f677b155b039bc2b3669eb
Date: 2024-06-18T22:34:26.404Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.19045
qcz commented 4 months ago

Yeah, the new advanced diff algorithm has a horrible user experience for larger files. When diffing two 4,5k XML files with the Compare selected function, it immediately starts to lag after the initial load, and later it ceases to do anything without any feedback to the user. It would be better if it did not react to any and all keypress for larger files, but do its thing in batches for predefined intervals.

bonzi-123 commented 3 months ago

I just wanted to add that I have had the same issue with large files - it just keeps loading forever with no error/warning message. The issue is very misleading because the diff works well with some of the big files, but not with others - so initially I thought I had some kind of connection issue or some other problem, but after a lot of going back and forth, I found this post and I was able to fix it by changing the diff algorithm to "legacy".