npx skills add ...
npx skills add nvidia/elements --skill guidance-webgpu-performance
Diagnose and improve browser WebGPU rendering performance, including frame pacing, draw and state-submission overhead, buffer uploads, shaders, and JavaScript work on the render critical path. Use for slow or stuttering GPU-backed interfaces, rendering regressions, CPU/GPU bottleneck analysis, renderer performance changes, or WebGPU resource, timing, diagnostic, and lifecycle test suites; do not use for general page-load, build performance, or CPU-only benchmark work.
npx skills add nvidia/elements --skill guidance-webgpu-performance
Find the limiting resource before changing the renderer. Produce a reproducible diagnosis that separates JavaScript preparation, browser/API submission, data transfer, and GPU execution, then make only changes supported by measurements.
AGENTS.md and the affected project's DEVELOPMENT.md.package.json, local Vitest benchmark configuration, existing *.test.bench.ts files, and any shared configuration they import. Do not assume another project's harness applies unchanged.*.test.webgpu.ts suite, choosing a test mode, or deciding whether a performance task belongs in CI.Define the workload and target before measuring:
git status --short and preserve unrelated changes. Record when measurements include a dirty worktree.Use independent CPU and GPU evidence plus controlled perturbations. Do not infer a GPU bottleneck from low FPS or a CPU bottleneck from a busy render callback alone.
If the evidence remains ambiguous, propose the smallest next experiment instead of recommending a large rewrite.
Discover the affected project's test:bench script, benchmark config, and *.test.bench.ts files before extending them. The repository's shared Vitest library benchmark configuration recognizes src/**/*.test.bench.ts, but the package's local config and DEVELOPMENT.md determine how to run it and what environment it uses.
Treat an ordinary Vitest benchmark as a CPU microbenchmark unless its configured environment and measured callback show otherwise. Timing data generation, validation, packing, dirty-range handling, or calls that prepare upload bytes does not measure GPUQueue.writeBuffer, command execution, shaders, presentation, or frame pacing.
Follow the affected package's established patterns:
Run commands from the affected project through mise and only when its DEVELOPMENT.md defines the script:
Keep baseline and candidate environment, workload, benchmark options, and worktree state comparable. Use browser instrumentation for any claim about GPU execution or end-to-end rendering.
Use the shared Node-hosted Vitest configuration and Playwright runner when an investigation must exercise the production WebGPU renderer without adding the Vitest browser client to the measured page. Import the configuration, runner,
utilities, and types from @internals/vite/webgpu; do not use the root package export or runner deep imports in new consumers.
Keep these evidence classes separate:
check mode uses headless software WebGPU for deterministic API-call, resource, upload, interaction, and cleanup invariants. Only this mode belongs in ordinary hosted CI, and it must not contain timing budgets.measure, diagnostic, and lifecycle modes require a native adapter and belong on a controlled local or dedicated GPU runner. Reject software fallback before interpreting results.test:bench remains a CPU/browser microbenchmark workflow. Use it for local baseline/candidate comparisons, but keep it out of required PR CI unless the repository adopts controlled runners and an explicit baseline policy.The consuming package owns its workload page, representative profiles, assertions, budgets, production-boundary rules, and scripts. The shared tooling owns browser and server lifecycle, adapter selection, external WebGPU observation, environment capture, DevTools traces, memory snapshots, statistics helpers, and artifact writing. See the reusable suite guide for the workload contract, observer limitations, Wireit setup, and validation rules.
Prefer reducing repeated work on the confirmed limiting path:
Treat advanced staging rings, indirect drawing, shader or compute rewrites, data-layout changes, and WebAssembly as experiments with added complexity. Require evidence that a simpler change cannot meet the target.
Also inspect bind-group and pipeline reuse, write frequency, buffer-offset alignment, command/pass structure, shader compilation, texture and attachment churn, and asynchronous mapping or readback behavior.
When the user asks only for diagnosis, report findings without changing code. When the user asks for an improvement, implement the smallest supported change and verify:
DEVELOPMENT.md;Report the workload, environment, measurements and spread, bottleneck classification, evidence, change or recommendation, confidence, and remaining uncertainty. State explicitly whether each result is a CPU microbenchmark, JavaScript frame measurement, GPU timer result, or end-to-end observation.