hex/perf/idle.bench.ts
Luke Parker 3f8aa05af1
perf(windows): tray Hex makes no GPU device at rest; the HUD still shows fast (Rune c448a35a) (#1229)
* perf(windows): tray Hex makes no GPU device until something shows

Rune 4c039671. The capture capsule, picker, and ink keep their windows from
launch but make their GPU surfaces only to show (release_gpu_when_hidden).
gpu-draw.pending is written when Rune starts the launch's first GPU device
(rune::on_gpu) and cleared by its first frame, so a tray launch that never
draws leaves no marker.

* perf(windows): the first HUD after rest shows without waiting for the GPU

Rune c448a35a. A first surface on a new device now takes about 210 ms to its
first present instead of 630 to 850 ms (precompiled DX12 uber shader, one
adapter enumeration). The HUD keeps its window from launch, keeps its GPU
surface for 5 minutes after its last hide (release_gpu_after), then gives the
device back. When the dictation shortcut's modifiers go down, Rune makes the
device and the HUD's pipeline on a thread (warm_gpu_with), so the HUD that
follows shows in about 15 ms.

* docs(capture): the picker is prewarmed again; it holds no GPU surface while hidden
2026-11-04 01:49:43 -06:00

47 lines
1.6 KiB
TypeScript

// Hex at rest, measured from outside (docs/perf.md): no input, no listener.
// Each run waits 8 s; strobe counts the process's CPU, thread wakeups and
// memory over it.
import { bench, native } from "@hona/strobe"
export default bench({
targets: {
// The Settings window open on General. Needs an unlocked session.
window: native("hex", { bridge: false }),
// A login launch: the tray only, no window. Runs on a locked session too.
tray: native("hex", { args: ["--hidden"], window: false, bridge: false }),
},
// Startup work (fonts, GPU, first frames) finishes before any run.
async setup({ page }) {
await page.wait(5_000)
},
cases: {
"window-open": {
targets: ["window"],
primary: "cpu.work",
metrics: ["cpu.wakes", "cpu.app.total", "gpu.process.3d", "memory.app.private"],
async run({ page }) {
await page.wait(8_000)
},
},
"window-closed": {
targets: ["tray"],
primary: "cpu.work",
metrics: ["cpu.wakes", "cpu.app.total", "memory.app.private"],
async run({ page }) {
await page.wait(8_000)
},
},
// The same tray, judged by what it holds. The capture capsule, picker,
// and ink wait hidden from launch; a GPU device, and their swapchains,
// count here and in gpu.vram. memory.app.host is Hex's own memory
// without the VRAM a driver maps into the process.
"window-closed-memory": {
targets: ["tray"],
primary: "memory.app.private",
metrics: ["cpu.wakes", "cpu.work", "gpu.vram", "memory.app.host"],
async run({ page }) {
await page.wait(8_000)
},
},
},
})