Repository navigation
fix: run the GPU compute benchmark on demand and release its buffer (#11) - #19
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
useGPUCompute no longer allocates or dispatches on mount. run() requests a device, performs 5 sequential dispatches, reports the median as an estimate, and destroys the buffer and device afterwards. Runs do not overlap, stop when the tab is hidden, and clean up on unmount. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…#11) The COMPUTE item gets a native button (accessible name "Run compute benchmark") that is aria-disabled while a run is in progress, and the COMPUTE value becomes a polite live region. MapView wires it to useGPUCompute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…trast table (#11) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…#11) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
Browsers can expose navigator.gpu while requestAdapter() returns null. The benchmark hook may not probe an adapter on mount, so the panel uses the tier from useGPUCapabilities. The plan's AC1 and AC10 are updated to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
… device loss in the GPU mock (#11) The console.error spy cannot detect a state update after unmount in React 19, so the unmount test no longer claims to. The mock device gains pushErrorScope, popErrorScope (resolving null), and a never-settling lost promise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
#11) A hidden tab or unmount while requestAdapter() or requestDevice() is pending now ends the run before the 64 MB buffer is allocated, and a device that arrives late is destroyed. run() after unmount does nothing. The plan's AC6, AC8, and Proof are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…#11) The plan's AC4 and Proof are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…as GB/s (#11) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
The run pushes out-of-memory and validation error scopes before setup and pops them after the loop, and races each onSubmittedWorkDone() against device.lost. A scope error or a loss not caused by our own destroy shows Failed. The plan's AC10 and Proof are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…ed (#11) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
The outcome now depends only on whether all 5 timings were collected. The plan's AC6 and Proof are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…tro (#11) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
Approved by the orchestrator under the user's delegation: the unused setVisibility() and hide() helpers, copied from the shared mock block, broke lint. No assertion changed. Recorded in the plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
…ne (#11) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
device.lost can settle in the same tick as the pending work-done, so the race may record a cut-short timing. After the loop, any recorded loss other than our own destroy now shows Failed. The plan's Proof is updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
Also covers a hide plus a device loss mid-run showing Failed, which the plan's Proof already claimed but no test checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
A loss that settles while the scopes are popped (they resolve null on a lost device) now shows Failed. The in-loop assignment is dropped because the post-pop check covers it. The plan's AC10 and Proof are updated, including the hide plus loss case that is now tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the GPU compute benchmark on demand. Nothing runs or allocates on mount any more. A
RUNbutton next to COMPUTE in the GPU info panel runs 5 sequential dispatches over the 64 MB buffer, reports the median as~X.X GB/s est., then destroys the buffer and the device.onSubmittedWorkDone()before the next. There is nosetInterval, and a second activation during a run does nothing (ref guard; the button getsaria-disabled="true"rather thandisabled, so focus stays).document.visibilityState === 'hidden'. Hiding the tab mid-run, including during adapter or device setup, stops it before the next dispatch or before the 64 MB allocation, and showsStopped. A run whose 5 dispatches already finished keeps its result.Failedinstead of a bogus number. A zero median from a coarse timer showsToo fastinstead of~Infinity.--accentfocus ring, 33.5x24 box, COMPUTE value is anaria-live="polite"region. The panel keepspointer-events: none; the button opts back in.webgpu, so with no adapter COMPUTE shows--with no button, as before.Not done, on purpose:
GPUDevicewithuseGPUHeatmap: the heatmap is one-shot and already destroys its device infinally, and the benchmark device now lives only for a user-started run. A shared long-lived device would hold GPU resources longer than either hook does now.timestamp-query: needs an optional feature, a query set, a resolve buffer and a map-read round trip. CPU timing is kept and labelledest..Plan
docs/plans/2026-11-07-issue-11-on-demand-gpu-benchmark.md, committed at 1dd2147 before any implementation. Revisions during the work, each in the commit that departed:useGPUCapabilitiesprobe and the one-shot heatmap already callrequestAdapteron mount.webgputier, because headless Chromium exposesnavigator.gpuwith no adapter and the hook may not probe on mount.Too fast, stop during setup, async errors and device loss).setVisibility()andhide()helpers were deleted fromsrc/hooks/useGPUCompute.tooFast.test.js(dead code that brokeno-unused-vars; no assertion changed). Approved by the orchestrator under the user's delegation; recorded in the plan.Test evidence
Gate on 114796c, run verbatim from the worktree root, all exit 0:
npm ci: found 0 vulnerabilitiesnpm run lint:eslint ., no outputnpm test: Test Files 24 passed (24), Tests 211 passed (211)npm run build: built in 1.00s (existing chunk-size warning only)npm audit --omit=dev --audit-level=high: found 0 vulnerabilitiesUnit tests with a mocked
navigator.gpucover: no work on mount; 5 strictly sequential dispatches; buffer and device destroyed after complete, stopped and failed runs; hidden before a run, during setup, mid-run, and during the last dispatch; overlap guard; unmount mid-run and during setup; null adapter; error scopes; device loss during a dispatch, together with the last work-done, and during the scope pops. Frozen regression tests:src/components/GPUInfoPanel.benchmarkTier.test.jsx,src/hooks/useGPUCompute.{setupStop,tooFast,asyncErrors,hiddenLast,lostWithWork,lostAfterLoop}.test.js.Live drive (built app,
vite preview, Playwright + Chromium 1254; headless Chromium hasnavigator.gpubut no adapter, so the WebGPU path used an injectednavigator.gpumock):WebGL Fallback, no button, COMPUTE--(also withnavigator.gpuundefined).:focus-visibleoutline 2px solid rgb(0, 255, 136), offset 2px; Enter and Space start a run;Running...witharia-disabled="true"and focus kept; result~0.4 GB/s est.on a 300 ms mock dispatch; 5 submits, 2 error scopes pushed and popped, 1 buffer and 1 device destroyed. Mouse click: same.Failed; device lost (unknown) mid-run, with the 5th work-done, and during the scope pops each showFailed; hidden duringrequestDeviceshowsStoppedwith no buffer created; hidden after dispatch 2 showsStoppedafter 2 submits; hidden during dispatch 5 keeps the result; double click plus Enter plus Space during a run gives 1 adapter request and 5 submits.Independent verifier (fresh context, its own mock and scripts) repeated the run, hidden-tab, failure, overlap, no-WebGPU and layout checks plus the layer panel and popup flows: no findings, no console errors.
Real Chrome (user's browser):
navigator.gpuis present butrequestAdapter()returns null on this machine, so the app showsWebGL Fallback, no RUN button and COMPUTE--. No real throughput number could be measured.Review findings
First round: three Claude finders (bugs and compliance; security and resource safety; outside the diff) and two Fable finders (bugs and compliance; edge cases), then a Claude confirmation pass. Fixed (source models in brackets):
run()after unmount did a full run. [claude x2, fable x2]~Infinity GB/s est.; nowToo fast. [claude, fable x2]device.lostrace, shown asFailed. [claude, fable]console.errorcheck was vacuous under React 19; removed. [claude, fable]Delta rounds (Claude): device loss settling together with the last work-done still showed GB/s (fixed); loss during the error scope pops still showed GB/s, and the hide-plus-loss case was claimed but untested (fixed, test added). Final delta round: no findings.
Dismissed: sequencing test called weak (the exact-count
waitForalready catches an overlapping submit); button border at about 2.9:1 (WCAG 1.4.11 is met by the 13:1RUNtext that identifies the control); layout evidence not in the branch (it is above).Left as nits: focus drops to
bodyif a run finds no adapter after the tier said WebGPU (rare: the button is then correctly removed); one test sleeps 1.1 s of real time; mock helpers are duplicated across the new test files; one frozen test assertsnot.toBe('Failed')where a regex would be stronger.Docs reconciled
README.md: intro, GPU info panel bullet, and Known limitations now describe the on-demand benchmark, its result states, and that RUN is hidden at 1024px and below.CLAUDE.md: no change needed; "a throughput readout" is still accurate.docs/: historical, no change.Closes #11
🤖 Generated with Claude Code
https://claude.ai/code/session_01AELE7jB1i3uqqrHu3SjJjf