Reuse display_map snapshot where possible to reduce snapshot creation - #30840
Reuse display_map snapshot where possible to reduce snapshot creation#30840RemcoSmitsDev wants to merge 12 commits into
Conversation
While I was debugging why the project search was slow I discoverd that we where making in a few cases multiple display_map snapshot within the same function root caller. This also popped up inside my instruments capture.
|
Thanks for this! I think the change is reasonable (in particular passing a display map instead of a cx to get selections makes sense). It obviously conflicts with a lot though, sorry for not reviewing faster. That said, I'm curious to see some numbers. Do you have a reproduction case in search and how much faster does this make it? (I also wonder if there's more we can do to make creating snapshots faster... cc @maxbrunsfeld). |
|
Hey, thanks for the review and no worries! I use the What would be the best way to measure this? This PR should also improve the performance of some vim code paths that use selections, but that might be harder to measure, I guess. Yeah, we might be able to improve the performance there, but hard to say because I'm not familiar with the code. |
a219635 to
6d69936
Compare
|
The way I've typically tested project search speed (though it isn't very scientific) is to set a global static when we start the search, and print out time elapsed when the 1st, 10th, 100th result has been added to the multibuffer. For large minified files, I wonder if we aren't also running into similar issues as #16120... |
|
Yeah, I think we can tackle that later as Anthony is fixing the tabmap performance issue. |
|
@ConradIrwin So my measurement does not say it's faster, which makes sense in a way because I'm not hitting the code path that originally created 2 snapshots instead of one. This one happens when line_mode is enabled, in the case of getting the newest_adjusted selection, for example. But for multiple vim code paths, we now only create one display snapshot, and each snapshot creation takes about ~300ms. I'm not a vim person, so it's hard to measure what the exact performance gain is there, but should be a ~2x. Before: (average 224.5260415ms) After: (average 226.93803125ms) |
2c27403 to
e6faad4
Compare
4ea0052 to
aa77f43
Compare
|
What's the status of this? (branch has gone stale and has merge conflicts) |
|
if we want to keep go forward with this pr happy to fix the big merge conflicts. After that might need a review |
|
I don't think this is going to be easy to land at all. Closing for now, but we can come back to it later |
Re-applies #30840 This PR re-applies the initial [PR](#30840). As it was closed because it was hard to land, because of the many conflicts. This PR re-applies the changes for it. In several cases we were creating multiple display_map snapshots within the same root-level function call. Creating a display_map snapshot is quite slow, and in some cases we were creating the snapshot multiple times. Release Notes: - N/A
Re-applies zed-industries/zed#30840 This PR re-applies the initial [PR](zed-industries/zed#30840). As it was closed because it was hard to land, because of the many conflicts. This PR re-applies the changes for it. In several cases we were creating multiple display_map snapshots within the same root-level function call. Creating a display_map snapshot is quite slow, and in some cases we were creating the snapshot multiple times. Release Notes: - N/A
While debugging the slow performance of the project search, I discovered that in several cases we were creating multiple display_map snapshots within the same root-level function call. I noticed that creating a display_map snapshot is quite slow, and found that in some cases we were generating the snapshot multiple times.
Release Notes: