zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
44.51k stars 2.4k forks source link

Replacing a lot of entries is still extremely slow compared to other editors #14408

Open maximeborges opened 1 month ago

maximeborges commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

When trying to replace a lot of tabs by semicolons in a CSV-like file, Zed basically froze for a few minutes (I killed it after 3 minutes). I was on 0.139.3, I checked the existing issues and saw that https://github.com/zed-industries/zed/issues/13455 (and even the file example from https://github.com/zed-industries/zed/issues/11210 takes tens of seconds just to load up) were fixed in 0.143.6, so I tried installing zed-preview-bin from AUR which currently is 0.144.2, but I don't really see much of an improvement.

Repro

You can generate a file with similar content to my test file with (210k matches):

for i in {1..30000}; do echo "$i\t$i\t$i\t$i\t$i\t$i\t$i\t$i" >> /tmp/test_file; done

Then in Zed, use the replace function with a tab char (either by pasting a tab char in the search field, or enabling regexp and using \t; both takes the same time on my machine) and use a semicolon in the replace field. This action takes about 45s, using 100% of a thread of my i7-1260p CPU. The same action takes less than half a second in VSCode, and is instantaneous in vim.

Environment

Zed: v0.144.2 (Zed Preview) OS: Linux Wayland manjaro unknown Memory: 31.1 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

No response

osiewicz commented 1 month ago

Thanks for reporting this interesting issue =) For what it's worth, this issue is a bit different than #13455 - in this case, our internal data structures (TabMap) which are responsible for tracking code layout take quite a bit to update since the # of changes is pretty large (210k to be exact).

maximeborges commented 1 month ago

I was thinking about some layout issue also, but since I currently have no clue on how displaying things on the screen is done in Zed, I thought maybe it was still something related to this previous issue. Good to know it's something different and I'm not badly testing the new release ^^

osiewicz commented 1 month ago

No, this is a very valid issue (and for the record, I can reproduce it just fine). Manual CSV processing is not unheard of, so I'll look into it. Thanks :)

osiewicz commented 1 month ago

The initial fix for it landed in https://github.com/zed-industries/zed/pull/14567, which will be released to Preview channel tomorrow. For me it slashed the time needed for the repro to complete from 13s to 2s, so if in your case I'd expect it to not require killing off the app at the very least. :) I'm gonna leave this issue open though, as there's still more that we can do.