gpui-bench

Design, run, and interpret production-shaped GPUI Criterion benchmarks.

89.5k|10.4k|Updated Feb 20, 2021
One-click install
npx skills add https://github.com/zed-industries/zed --skill gpui-bench
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gpui-bench
Source: https://github.com/zed-industries/zed/tree/main/.agents/skills/gpui-bench
Command: npx skills add https://github.com/zed-industries/zed --skill gpui-bench

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Benchmarking GPUI code is difficult because naive Criterion setups often enable test-only features, use fake executors, or skip the rendering pipeline, producing numbers that do not reflect real UI responsiveness. This Skill enforces production-faithful benchmarking so that frame drops, hangs, and foreground stalls can be reproduced and measured reliably.

Core Features & Use Cases

  • Production-path modeling: Map the real trigger, queue, executor, and render path into the benchmark fixture, including headless Metal frame submission on macOS.
  • Feature isolation: Verify the benchmark feature graph contains zero test-support occurrences and uses narrow bench-support seams.
  • Responsiveness metrics: Measure foreground poll latency, frame-budget overruns, dirty-to-draw delay, and completion throughput together, not throughput alone.
  • Use Case: A user reports scrolling hitches after a queue refactor. Use this Skill to write a bench_renderer benchmark that drives a concurrent producer past queue capacity, captures p99 foreground latency and frame overruns on baseline and candidate commits, and reports whether the fix actually improves responsiveness.

Quick Start

Use the gpui-bench skill to write a production-shaped Criterion benchmark that reproduces the reported scrolling hitch and reports before/after foreground latency and frame-budget overruns.

Frequently Asked Questions about gpui-bench

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a GPUI benchmark that reproduces a UI hang?

Use `#[gpui::bench]` with `bench_batched_task` or `bench_renderer`, drive more work than the queue capacity, keep a concurrent producer refilling it, and include a responsiveness signal such as a spinner or scrolling viewport. Assert final work counts and ordering outside the timed region.

What is the difference between bench_iter, bench_task, and bench_renderer in GPUI?

`bench_iter` measures synchronous compute work, `bench_task` measures an async GPUI Task to completion including foreground polls and draws, and `bench_renderer` updates an entity in a window and submits a frame through the headless renderer. Choose based on whether the operation is sync, async, or render-driven.

Does GPUI benchmarking work on Linux and Windows?

GPUI performs CPU-side window work on all platforms, but only macOS has a headless Metal renderer that submits real GPU frames. On Linux and Windows the present step discards the scene, so results must state this limitation and supplement with app automation or platform profilers.

Why is test-support forbidden in GPUI benchmark feature graphs?

Enabling `test-support` brings in fake executors, deterministic clocks, and test-only CRDT settings that change scheduling behavior and invalidate responsiveness measurements. Use the `bench-support` feature with narrow production-faithful seams instead, and verify with `cargo tree -e features`.

How do I compare benchmark results between two commits fairly?

Keep the benchmark code identical between baseline and candidate, build both with the same optimized profile and lockfile, run on the same machine, alternate runs to reduce thermal bias, and report raw percentiles plus confidence intervals rather than only percentage changes.