Commit aa81505
multibuffer: Speed up anchor resolution by avoiding an excerpts seek (#53340)
Before, every creation of `AnchorSeekTarget` called
`MultiBufferSnapshot::buffer_for_path`, which seeks the excerpts sum
tree. Now we avoid that by
- looking up the buffer snapshot for the anchor's buffer in the
`buffers` map (keyed by `BufferId`)
- handling the case where the anchor's buffer doesn't exist at the
original path key with a separate `AnchorSeekTarget::Missing` variant
We also added a separate optimization to `AnchorSeekTarget::cmp`, to
skip the full `PathKey` comparison when the cursor's `PathKeyIndex` is
the same as the anchor's. This should help with singleton multibuffers.
Self-Review Checklist:
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- N/A
---------
Co-authored-by: Anthony Eid <hello@anthonyeid.me>1 parent 36a23c2 commit aa81505
2 files changed
+75
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
43 | 48 | | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
47 | | - | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
59 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
60 | 71 | | |
61 | 72 | | |
62 | 73 | | |
| |||
110 | 121 | | |
111 | 122 | | |
112 | 123 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
119 | 132 | | |
120 | 133 | | |
121 | | - | |
122 | 134 | | |
123 | 135 | | |
124 | 136 | | |
| |||
234 | 246 | | |
235 | 247 | | |
236 | 248 | | |
237 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
238 | 253 | | |
239 | 254 | | |
240 | 255 | | |
241 | 256 | | |
242 | | - | |
| 257 | + | |
243 | 258 | | |
244 | | - | |
245 | | - | |
| 259 | + | |
| 260 | + | |
246 | 261 | | |
247 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
248 | 271 | | |
249 | 272 | | |
250 | | - | |
251 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
252 | 276 | | |
253 | 277 | | |
254 | 278 | | |
| |||
372 | 396 | | |
373 | 397 | | |
374 | 398 | | |
375 | | - | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
376 | 403 | | |
377 | 404 | | |
378 | 405 | | |
| |||
406 | 433 | | |
407 | 434 | | |
408 | 435 | | |
409 | | - | |
| 436 | + | |
410 | 437 | | |
411 | | - | |
412 | | - | |
| 438 | + | |
| 439 | + | |
413 | 440 | | |
414 | 441 | | |
415 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
870 | 870 | | |
871 | 871 | | |
872 | 872 | | |
| 873 | + | |
873 | 874 | | |
874 | 875 | | |
875 | 876 | | |
| |||
880 | 881 | | |
881 | 882 | | |
882 | 883 | | |
| 884 | + | |
883 | 885 | | |
884 | 886 | | |
885 | 887 | | |
| |||
6386 | 6388 | | |
6387 | 6389 | | |
6388 | 6390 | | |
6389 | | - | |
6390 | | - | |
| 6391 | + | |
| 6392 | + | |
6391 | 6393 | | |
6392 | 6394 | | |
6393 | | - | |
| 6395 | + | |
6394 | 6396 | | |
6395 | 6397 | | |
6396 | 6398 | | |
| |||
7327 | 7329 | | |
7328 | 7330 | | |
7329 | 7331 | | |
| 7332 | + | |
7330 | 7333 | | |
7331 | 7334 | | |
7332 | 7335 | | |
| |||
7425 | 7428 | | |
7426 | 7429 | | |
7427 | 7430 | | |
| 7431 | + | |
7428 | 7432 | | |
7429 | 7433 | | |
7430 | 7434 | | |
7431 | 7435 | | |
7432 | 7436 | | |
7433 | 7437 | | |
7434 | 7438 | | |
7435 | | - | |
| 7439 | + | |
7436 | 7440 | | |
7437 | 7441 | | |
7438 | 7442 | | |
7439 | 7443 | | |
7440 | 7444 | | |
7441 | 7445 | | |
| 7446 | + | |
| 7447 | + | |
| 7448 | + | |
| 7449 | + | |
| 7450 | + | |
| 7451 | + | |
| 7452 | + | |
7442 | 7453 | | |
7443 | 7454 | | |
| 7455 | + | |
7444 | 7456 | | |
7445 | 7457 | | |
7446 | 7458 | | |
7447 | | - | |
7448 | | - | |
7449 | | - | |
7450 | | - | |
7451 | | - | |
7452 | | - | |
7453 | | - | |
7454 | | - | |
7455 | | - | |
7456 | | - | |
7457 | | - | |
7458 | | - | |
| 7459 | + | |
| 7460 | + | |
| 7461 | + | |
| 7462 | + | |
| 7463 | + | |
7459 | 7464 | | |
7460 | | - | |
7461 | | - | |
7462 | | - | |
| 7465 | + | |
7463 | 7466 | | |
7464 | 7467 | | |
7465 | | - | |
7466 | | - | |
| 7468 | + | |
7467 | 7469 | | |
7468 | 7470 | | |
7469 | 7471 | | |
| |||
0 commit comments