Files
zed/crates/gpui_platform/Cargo.toml
T
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

82 lines
2.2 KiB
TOML

[package]
name = "gpui_platform"
version = "0.1.0"
edition.workspace = true
publish.workspace = true
license = "Apache-2.0"
[lints]
workspace = true
[lib]
path = "src/gpui_platform.rs"
doctest = false
[features]
default = ["multithreaded"]
# Threads in the browser: needs a nightly toolchain and a cross-origin-isolated
# page. Off, gpui_web builds on stable.
multithreaded = ["gpui_web/multithreaded"]
bench-support = ["gpui/bench-support", "gpui_macos/bench-support", "gpui_wgpu/bench-support"]
font-kit = ["gpui_macos/font-kit"]
inspector = ["gpui/inspector"]
test-support = ["gpui/test-support", "gpui_macos/test-support", "gpui_windows/test-support", "gpui_wgpu/test-support"]
screen-capture = ["gpui/screen-capture", "gpui_macos/screen-capture", "gpui_windows/screen-capture", "gpui_linux/screen-capture"]
runtime_shaders = ["gpui_macos/runtime_shaders", "gpui_ios/runtime_shaders"]
wayland = ["gpui_linux/wayland"]
x11 = ["gpui_linux/x11"]
[[bench]]
name = "atlas_upload"
harness = false
required-features = ["bench-support"]
[[bench]]
name = "focus_cleanup"
path = "../gpui/benches/focus_cleanup.rs"
harness = false
required-features = ["bench-support"]
[[bench]]
name = "inspector_render"
harness = false
required-features = ["bench-support"]
[[bench]]
name = "randomized_element_tree"
harness = false
required-features = ["bench-support"]
[[bench]]
name = "primitives"
harness = false
required-features = ["bench-support"]
[dependencies]
anyhow.workspace = true
gpui.workspace = true
[dev-dependencies]
bench_metrics.workspace = true
criterion.workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
gpui_macos.workspace = true
[target.'cfg(target_os = "ios")'.dependencies]
gpui_ios.workspace = true
[target.'cfg(target_os = "windows")'.dependencies]
gpui_windows.workspace = true
gpui = { workspace = true, features = ["windows-manifest"] }
[target.'cfg(all(any(target_os = "linux", target_os = "freebsd"), not(target_env = "ohos")))'.dependencies]
gpui_linux.workspace = true
[target.'cfg(target_os = "linux")'.dependencies]
gpui_wgpu = { workspace = true, optional = true }
[target.'cfg(target_family = "wasm")'.dependencies]
gpui_web.workspace = true
console_error_panic_hook.workspace = true