Commit Graph

2 Commits

Author SHA1 Message Date
Anthony Eid 4ce4b7b567 gpui: Move a Div's Interactivity out of line (#66719)
## Summary

Tessellating vector paths dominates the randomized element tree's
frames, hiding layout and the rest of the frame. This adds a
`with_paths(false)` option (the canvas stays, so layout is unchanged),
`PathlessTree/full refresh` and `PathlessTree/element style` benchmark
groups, and adds the path-free full refresh to
`script/gpui-bench-compare`'s core suite.

It also adds a random text mutation to the randomized element tree, so
its tests cover text whose measured size changes (including text that
wraps and text that's removed). Generated trees are unchanged, but the
extra mutation kind changes which mutations each seed applies.

These PRs are stacked on this one and use its path-free groups for their
benchmark numbers:

- #66723 gpui: Move a Div's Interactivity out of line (merged into this
branch)
- #66720 gpui: Only take a line wrapper when truncating text
- #66721 gpui: Compute tab stop order only when moving focus
- #66722 gpui: Trim per-line and per-glyph work in the text system

Release Notes:

- N/A
- [GPUI] Improve randomize element tree test
2026-11-09 04:15:58 +00:00
Anthony Eid 26abd1c959 gpui_platform: Extend benchmarks and add a two-revision comparison script (#66316)
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
2026-11-02 02:46:28 +00:00