mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-03 14:01:30 +01:00
8202394e98
## Summary
Follow-up to #67023.
After skipping equal 16-byte chunks, `RelPath::cmp` scanned for the
first differing byte one at a time. It now takes the index from the XOR
of the two chunks and, when the paths share at least 16 bytes, checks
the tail as one 16-byte window. The order is unchanged.
Change in time per comparison on about 103,700 paths from a Linux
checkout. Scan replay repeats the 1.46M comparisons that a scan of a
Linux checkout makes, in order. Release build, median of 31 alternating
rounds; the 9800X3D run is pinned to one core:
| Machine | Scan replay | Sorted neighbours | Equal paths | Random pairs
| Sorting all paths |
|---|---|---|---|---|---|
| Ryzen 7 9800X3D | −31% | −56% | −61% | −12% | −41% |
| `ubuntu-latest`, Xeon Platinum 8573C | −33% | −58% | −57% | −18% |
−45% |
| `ubuntu-24.04-arm`, Neoverse-N2 | −31% | −43% | −47% | −2% | −36% |
| `macos-latest`, Apple M1 | −33% | −53% | −58% | −33% | −44% |
| `windows-latest`, EPYC 9V74 | −27% | −48% | −54% | −16% | −40% |
Replayed scan comparisons of the Zed, Linux, and Firefox trees are
27–35% faster on every machine. Random pairs gain least: across the
three path lists they range from 54% faster to 12% slower (Firefox paths
on `windows-latest`).
Change in initial scan time with `Worktree::local` and `RealFs` in a
headless app on a3ce8d5e88, one scan per process, warm file cache.
GitHub-hosted runners have 4 vCPUs, 3 on macOS. Runs where the PR was
faster are in parentheses:
| Tree | Entries | Ryzen 7 9800X3D, 16 threads | `ubuntu-latest` |
`ubuntu-24.04-arm` | `macos-latest` | `windows-latest` |
|---|---|---|---|---|---|---|
| Linux | 112,000–121,000 | −2.6% (41/41) | −0.8% (63/101) | −0.8%
(68/101) | −6.9% (63/101) | −0.1% (22/41) |
| Firefox | 532,000–536,000 | −4.3% (29/31) | −0.2% (23/41) | −0.6%
(25/41) | −5.6% (25/41) | −0.2% (9/15) |
| Zed | 5,300–5,400 | −2.9% (29/41) | +0.9% (49/101) | −1.0% (63/101) |
−3.4% (51/101) | −1.2% (23/41) |
On the Linux and Windows runners, scans change by 1.2% or less, and
`macos-latest` times vary too much between runs to tell. CPU time falls
1.6–2.2% on the 9800X3D and changes by under 1% on the Linux and Windows
runners. Both versions found the same entries in every run.
[Harness](https://github.com/ptweezy/zed/tree/bench-relpath-cmp-xor-v3/bench/rel_path_cmp_bench).
## Testing
- Three 16-byte test paths make pairs differ inside a full chunk.
Without them, dropping `chunk_index * CHUNK` from the index passed the
test.
- Matched the previous `cmp` on 13.3M arbitrary string pairs, with
overflow checks on.
- Before timing, the benchmark checks `cmp` against the component order
on 644,898 Zed, Linux, and Firefox paths and 11.4M recorded scan
comparisons, on x86_64 and aarch64 runners.
- `cargo test -p path` and `./script/clippy -p path` pass.
## Self-review
- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.
Release Notes:
- N/A