mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 15:10:34 +01:00
26abd1c959
Extends the GPUI benchmarks in `gpui_platform` and adds `script/gpui-bench-compare` for quick before/after comparisons. No runtime behavior changes. The only new GPUI APIs are `bench-support`-only: `Window::rendered_scene()` and `BenchWindowContext::simulate_resize`. ## Benchmarks - **`RandomizedTree/mixed` and `CachedTree/mixed`:** the general benchmark. Each iteration applies a fixed, seeded sequence of changes to a freshly built tree, one per frame: restyles, resizes, structural edits, reorders, pointer moves, scroll events, focus moves and window resizes, while some entities animate. Every iteration does exactly the same work. - **Single-change groups:** element style, leaf bounds, root layout, insert/remove, reorder and hover. They explain where a difference in the mixed workload comes from. - **`CachedTree`:** the same workloads with entities wrapped in `.cached()`. - **`TextPanels`, `Scroll` and `LayoutChurn`:** text updates and first frames, three scrolling workloads, and entity/ID/text churn. `LayoutChurn` also prints a heap check before timing. - **`Primitives`:** seeded random quads, shadows, underlines, paths and text, plus fixed overlap patterns, painted through a window and directly on `Scene`. - **The randomized tree fixture:** now draws paths, shadows, scroll containers, text, hover styles and optional animations. The benchmarks don't check their output; that's left to the fixture's tests. On macOS and Linux, frames include GPU submission through the headless renderer. Text benchmarks are skipped on Windows and on macOS without `font-kit`, because neither has a real headless text system. ## Comparison script `script/gpui-bench-compare BASE NEW` builds both revisions once and alternates short runs of 25 core cases. It reports foreground instructions per frame, wall time and run-to-run spread, in about 3 minutes. It also accepts `--filter`, `--full`, `--repetitions` and `--slow`. Both revisions must include this PR. ## Validation - A/A runs: within ±0.15% on the mixed cases and ±0.34% or better on the core suite. - All 193 `--test` cases pass (`SEED=0 ITERATIONS=1`, `bench-support,font-kit,inspector`). - The fixture's tests and `./script/clippy` pass. - A full `cargo bench` takes about 13 minutes on an M-series Mac. I haven't run it on Linux. ## Follow-ups - Add hiding the root to `CachedTree/mixed` once the `.cached()` visibility bug is fixed. - Add text edits, keyboard input, scale changes, overlays, virtual lists, images and drag and drop to the mixed workload. - Add images and SVG icons to the `Primitives` random case. - Measure GPU time, memory and upload bandwidth next to CPU instructions. - Cover hover and animation in the fixture's render-equivalence test. - Bring the window-painted `Primitives` random case into the core suite once GPU noise is separated out. Release Notes: - [GPUI] Added a mixed-workload benchmark, plus cached-view, hover, text, scrolling, layout-churn and primitive benchmarks, and `script/gpui-bench-compare` for quick instruction-count comparisons between two revisions