Skip to content

GPU meter#97

Merged
jayvdb merged 1 commit into
mainfrom
webgpumon
Jul 22, 2026
Merged

GPU meter#97
jayvdb merged 1 commit into
mainfrom
webgpumon

Conversation

@jayvdb

@jayvdb jayvdb commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added a GPU performance meter overlay to the web interface.
    • The overlay supports dragging, resizing, and closing.
    • GPU timing is displayed when WebGPU is available.
  • Bug Fixes

    • Preserved the overlay’s canvas sizing while maintaining existing video and canvas styling.
  • Tests

    • Expanded module checks to verify the GPU monitoring package is available.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds stats-gl runtime packaging and module resolution, introduces a WebGPU GPU utilization overlay with drag/resize/close controls, loads it in the websocket UI, scopes canvas styling, and updates related validation guidance and tests.

Changes

GPU meter overlay

Layer / File(s) Summary
Runtime dependency and module wiring
.mise/config.js.toml, libs/edge-toolkit/..., services/ws-server/Dockerfile, services/ws-server/static/package.json, services/modules/tests/api_modules.rs
Registers, packages, resolves, and verifies the stats-gl runtime module.
WebGPU meter implementation
services/ws-server/static/meters.js
Adds WebGPU timestamp probing, stats-gl rendering, panel interaction controls, and device-loss handling.
Page integration and verification
services/ws-server/static/index.html, services/ws-server/static/style.css, config/ast-grep/..., CLAUDE.md
Loads meters.js, scopes canvas styling to main, expands the documentation rule allowlist, and prioritizes functional verification before checks.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant meters.js
  participant WebGPU
  participant stats-gl
  Browser->>meters.js: load module
  meters.js->>WebGPU: request timestamp-query device
  meters.js->>stats-gl: create GPU panel
  meters.js->>WebGPU: dispatch probe each frame
  WebGPU->>stats-gl: provide probe timing
  stats-gl->>Browser: render GPU meter
Loading

Possibly related PRs

  • edge-toolkit/core#95: Changes dropdown filtering that may affect whether stats-gl appears in the module list.

Suggested reviewers: pierre-tenedero

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: adding a GPU meter/overlay.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch webgpumon

Comment @coderabbitai help to get the list of available commands.

@deepsource-io

deepsource-io Bot commented Jul 21, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 49edf37...2ecbaae on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Coverage  

Code Review Summary

Analyzer Status Updated (UTC) Details
C# Jul 21, 2026 11:48p.m. Review ↗
C & C++ Jul 21, 2026 11:48p.m. Review ↗
Docker Jul 21, 2026 11:48p.m. Review ↗
Java Jul 21, 2026 11:48p.m. Review ↗
JavaScript Jul 21, 2026 11:48p.m. Review ↗
Python Jul 21, 2026 11:48p.m. Review ↗
Rust Jul 21, 2026 11:48p.m. Review ↗
Secrets Jul 21, 2026 11:48p.m. Review ↗
Code coverage Jul 22, 2026 12:12a.m. Review ↗

Code Coverage Summary

Language Line Coverage (New Code) Line Coverage (Overall)
Aggregate
80%
57.2%
[▼ down 0.1% from main]
Python -
69.7%
Rust
80%
56.6%
[▼ down 0.1% from main]

➟ Additional coverage metrics may have been reported. See full coverage report ↗


Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

// corner; it can be dragged anywhere, resized from its bottom-right corner handle, and closed with
// the corner x button, which also stops the probe and releases the WebGPU device.

import Stats from "/modules/stats-gl/dist/main.js";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'


Found non-compliant syntax. Confirm that there are no syntax errors before committing your code to a version control system.

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 5 high · 1 minor

Alerts:
⚠ 6 issues (≤ 0 issues of at least minor severity)

Results:
6 new issues

Category Results
ErrorProne 5 high
CodeStyle 1 minor

View in Codacy

🟢 Metrics 38 complexity · 0 duplication

Metric Results
Complexity 38
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jayvdb
jayvdb marked this pull request as ready for review July 22, 2026 00:06
@jayvdb
jayvdb requested a review from pierre-tenedero July 22, 2026 00:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.mise/config.js.toml (1)

19-19: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Pin stats-gl to one exact version across all three paths. latest, *, and the unversioned pnpm add can drift independently, so the local module, static package, and container can end up on different releases.

  • .mise/config.js.toml
  • services/ws-server/static/package.json
  • services/ws-server/Dockerfile
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.mise/config.js.toml at line 19, Pin stats-gl to one identical exact version
in .mise/config.js.toml:19, services/ws-server/static/package.json:16, and
services/ws-server/Dockerfile:26, replacing latest, wildcard, or unversioned
installation references while preserving each file’s existing configuration
style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@libs/edge-toolkit/src/config.rs`:
- Around line 132-133: The first summary lines in both Rust files lack terminal
punctuation. Update the stats-gl summary in libs/edge-toolkit/src/config.rs
lines 132-133 and the JS-package summary in
services/modules/tests/api_modules.rs lines 44-46 to end with ., !, or ?; also
add libs/edge-toolkit/src/config.rs to the sorted allowlist in
doc-summary-ends-with-period.yaml.

In `@services/ws-server/static/meters.js`:
- Around line 125-158: The GPU meter lifecycle lacks centralized teardown,
leaving animation and global listeners active after closure or device loss. Add
an idempotent stop() in the GPU meter setup that cancels the RAF, removes window
listeners, removes the overlay, and disposes Stats; invoke it on close, setup
failure, and device.lost, while reusing the existing listener and overlay
references.

---

Nitpick comments:
In @.mise/config.js.toml:
- Line 19: Pin stats-gl to one identical exact version in
.mise/config.js.toml:19, services/ws-server/static/package.json:16, and
services/ws-server/Dockerfile:26, replacing latest, wildcard, or unversioned
installation references while preserving each file’s existing configuration
style.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 21ca55ed-0f45-45e4-bb93-d682d9ade392

📥 Commits

Reviewing files that changed from the base of the PR and between 49edf37 and 2ecbaae.

📒 Files selected for processing (10)
  • .mise/config.js.toml
  • CLAUDE.md
  • config/ast-grep/rules/doc-summary-ends-with-period.yaml
  • libs/edge-toolkit/src/config.rs
  • services/modules/tests/api_modules.rs
  • services/ws-server/Dockerfile
  • services/ws-server/static/index.html
  • services/ws-server/static/meters.js
  • services/ws-server/static/package.json
  • services/ws-server/static/style.css

Comment on lines +132 to +133
// stats-gl (the GPU utilisation meter overlay on the ws-server index page). Same
// npm-package-served-as-a-module pattern as onnxruntime-web above.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Terminate the new Rust comment summaries with punctuation.

Both files are covered by doc-summary-ends-with-period.yaml, but their added first summary lines end without ., !, or ?.

  • libs/edge-toolkit/src/config.rs#L132-L133: end the first stats-gl summary sentence with terminal punctuation.
  • services/modules/tests/api_modules.rs#L44-L46: end the first JS-package summary sentence with terminal punctuation.

As per coding guidelines, **/*.rs: "Whenever modifying a Rust file, add it to the sorted allowlist in doc-summary-ends-with-period.yaml and fix first-line doc summaries so they end in ., !, or ?."

📍 Affects 2 files
  • libs/edge-toolkit/src/config.rs#L132-L133 (this comment)
  • services/modules/tests/api_modules.rs#L44-L46
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@libs/edge-toolkit/src/config.rs` around lines 132 - 133, The first summary
lines in both Rust files lack terminal punctuation. Update the stats-gl summary
in libs/edge-toolkit/src/config.rs lines 132-133 and the JS-package summary in
services/modules/tests/api_modules.rs lines 44-46 to end with ., !, or ?; also
add libs/edge-toolkit/src/config.rs to the sorted allowlist in
doc-summary-ends-with-period.yaml.

Source: Coding guidelines

Comment on lines +125 to +158
const makeDraggable = (el) => {
let activePointerId = null;
let offsetX = 0;
let offsetY = 0;
el.style.cursor = "grab";
el.style.touchAction = "none";

el.addEventListener("pointerdown", (event) => {
activePointerId = event.pointerId;
offsetX = event.clientX - el.offsetLeft;
offsetY = event.clientY - el.offsetTop;
el.style.cursor = "grabbing";
event.preventDefault();
});

window.addEventListener("pointermove", (event) => {
if (activePointerId === null || event.pointerId !== activePointerId) {
return;
}
const x = event.clientX - offsetX;
const y = event.clientY - offsetY;
el.style.left = `${Math.min(Math.max(x, 0), window.innerWidth - el.offsetWidth)}px`;
el.style.top = `${Math.min(Math.max(y, 0), window.innerHeight - el.offsetHeight)}px`;
});

const release = (event) => {
if (event.pointerId === activePointerId) {
activePointerId = null;
el.style.cursor = "grab";
}
};
window.addEventListener("pointerup", release);
window.addEventListener("pointercancel", release);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

git ls-files services/ws-server/static/meters.js && wc -l services/ws-server/static/meters.js && sed -n '1,260p' services/ws-server/static/meters.js

Repository: edge-toolkit/core

Length of output: 9694


🏁 Script executed:

python3 - <<'PY'
from pathlib import Path
p = Path('services/ws-server/static/meters.js')
print(p.exists(), p.stat().st_size if p.exists() else None)
PY

Repository: edge-toolkit/core

Length of output: 165


🏁 Script executed:

rg -n "makeDraggable|device\\.lost|stats-gl|requestAnimationFrame|pointerdown|pointermove|pointerup|pointercancel" services/ws-server/static/meters.js

Repository: edge-toolkit/core

Length of output: 1637


🏁 Script executed:

sed -n '1,340p' services/ws-server/static/meters.js

Repository: edge-toolkit/core

Length of output: 10129


Centralize GPU meter teardown. Add an idempotent stop() that cancels RAF, removes the window listeners, removes the overlay, and disposes Stats on close, setup failure, and device.lost; otherwise the global listeners keep the overlay reachable and the frame loop keeps running after device loss.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@services/ws-server/static/meters.js` around lines 125 - 158, The GPU meter
lifecycle lacks centralized teardown, leaving animation and global listeners
active after closure or device loss. Add an idempotent stop() in the GPU meter
setup that cancels the RAF, removes window listeners, removes the overlay, and
disposes Stats; invoke it on close, setup failure, and device.lost, while
reusing the existing listener and overlay references.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
libs/edge-toolkit/src/config.rs 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@jayvdb
jayvdb merged commit 30f92d3 into main Jul 22, 2026
30 of 34 checks passed
@jayvdb
jayvdb deleted the webgpumon branch July 22, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants