Skip to content

feat(viz): expose lifetime stats on LosQueryManager - #78

Merged
WomB0ComB0 merged 2 commits into
mainfrom
feat/webgpu-los-stats
Apr 29, 2026
Merged

WomB0ComB0 merged 2 commits into
mainfrom
feat/webgpu-los-stats

Conversation

@WomB0ComB0

@WomB0ComB0 WomB0ComB0 commented Apr 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • The audit routine flags "queries dropping under load?" as a known sensor-stack risk. The manager itself never drops — it queues per-slot via .then() chains — so the real signal is slot depth.
  • Add a public stats getter returning { totalQueries, totalRays, peakSlotDepth }. peakSlotDepth > 1 means callers are pushing harder than GPU + readback can settle on a single slot; an audit script or overlay can read this directly.
  • Pure additive observability. No behaviour change to mesh-link / LiDAR consumers.

Test plan

  • npm run build passes; main bundle unchanged at 808.9 KB
  • tsc --noEmit clean
  • LosQueryStats exported alongside LosRay for typed downstream consumers
  • CI: client-budget, .NET CI, security gates

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added performance metrics tracking for query operations, including total queries processed, rays computed, and peak resource utilization.
  • Bug Fixes

    • Improved query failure handling to ensure consistent cleanup regardless of success or failure outcomes.

The audit routine asks "are queries dropping under load?" — the
manager doesn't drop, it queues per-slot via `.then()` chains. Add a
public `stats` getter (`totalQueries`, `totalRays`, `peakSlotDepth`)
so an audit script (or future overlay) can confirm whether the ring
buffer is enough or callers are queueing waiting for GPU + readback.

`peakSlotDepth` of 1 means the GPU finished before the next query
arrived on the same slot; > 1 means the simulation is pushing harder
than the dispatch can settle.

Pure additive observability — no behavioural change to existing
mesh-link / LiDAR consumers. Sensor chunk +~150 B; main bundle
unchanged at 808.9 KB.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cdadf3c6-e29f-4f3c-9056-ec372455d118

📥 Commits

Reviewing files that changed from the base of the PR and between 4f117fe and 9125b6f.

📒 Files selected for processing (1)
  • src/ResQ.Viz.Web/client/webgpu/los.ts

📝 Walkthrough

Walkthrough

The LosQueryManager class now tracks lifetime query metrics through a new exported LosQueryStats type and a stats getter. Slots are enhanced with depth counters that increment on query assignment and decrement when promises settle. Promise chain handling is refactored to ensure proper cleanup on both success and failure outcomes.

Changes

Cohort / File(s) Summary
Query Metrics Tracking
src/ResQ.Viz.Web/client/webgpu/los.ts
Added LosQueryStats export type with totalQueries, totalRays, and peakSlotDepth counters. Introduced per-slot depth tracking that increments on assignment and decrements on promise settlement. Refactored promise tail from .catch() to .then(decrement, decrement) to ensure cleanup on both success and failure paths. Manager counters updated on each accepted query.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through metrics bright,
Counting queries, depths in flight,
When promises settle, left or right,
Counters dance, the ledgers tight! ✨

🚥 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 'feat(viz): expose lifetime stats on LosQueryManager' accurately and concisely summarizes the main change: exposing a new stats getter on LosQueryManager for lifetime query metrics observability.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/webgpu-los-stats

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds performance and usage tracking to the LosQueryManager by introducing a LosQueryStats type and a depth counter for each Slot. The query method was updated to maintain these statistics, including total queries, total rays, and peak slot depth, while ensuring the depth counter is decremented via a refined promise chain. I have no feedback to provide.

@WomB0ComB0
WomB0ComB0 merged commit 6afd38a into main Apr 29, 2026
37 checks passed
@WomB0ComB0
WomB0ComB0 deleted the feat/webgpu-los-stats branch April 29, 2026 02:08
WomB0ComB0 added a commit that referenced this pull request Apr 29, 2026
Surfaces the LosQueryStats added in PRs #78/#79 in a small dev/audit
panel. Lets an operator confirm the WebGPU sensor primitive is
healthy without dropping into devtools — useful both for the
2026-05-12 audit routine (P2 #5) and during dev when tuning ring
sizing or world extents.

- New `client/sensorStatsOverlay.ts` — `SensorStatsOverlay` class
  builds a fixed bottom-left panel, hidden by default. Press 'i'
  (KeyI; ignored when typing in inputs) to toggle.
- Two sections (mesh-link, lidar) showing totalQueries / totalRays
  / peakSlotDepth / raysOutsideWorld. Cells colour amber when peak
  slot depth > 1 (callers queueing) or outside-AABB > 0 (sim is
  outside the brick map's coverage; project memory documents the
  4 km terrain vs 1 km sensor world gap).
- `update()` is called once per `ReceiveFrame`; short-circuits when
  the panel is hidden, so the closed-overlay cost is one boolean.
- Falls back gracefully when `getSensorContext()` returns null
  (no-WebGPU browser, init failure) — the panel just shows "offline".

Bundle: 809.0 → 811.3 KB (+2.3 KB; 99.0 % of the 800 KiB cap). Lands
much more comfortably on top of #82 (defer-signalr), which would
take this combined to ~756 KB.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
WomB0ComB0 added a commit that referenced this pull request Apr 29, 2026
* feat(viz): sensor-stats overlay (toggle with 'i')

Surfaces the LosQueryStats added in PRs #78/#79 in a small dev/audit
panel. Lets an operator confirm the WebGPU sensor primitive is
healthy without dropping into devtools — useful both for the
2026-05-12 audit routine (P2 #5) and during dev when tuning ring
sizing or world extents.

- New `client/sensorStatsOverlay.ts` — `SensorStatsOverlay` class
  builds a fixed bottom-left panel, hidden by default. Press 'i'
  (KeyI; ignored when typing in inputs) to toggle.
- Two sections (mesh-link, lidar) showing totalQueries / totalRays
  / peakSlotDepth / raysOutsideWorld. Cells colour amber when peak
  slot depth > 1 (callers queueing) or outside-AABB > 0 (sim is
  outside the brick map's coverage; project memory documents the
  4 km terrain vs 1 km sensor world gap).
- `update()` is called once per `ReceiveFrame`; short-circuits when
  the panel is hidden, so the closed-overlay cost is one boolean.
- Falls back gracefully when `getSensorContext()` returns null
  (no-WebGPU browser, init failure) — the panel just shows "offline".

Bundle: 809.0 → 811.3 KB (+2.3 KB; 99.0 % of the 800 KiB cap). Lands
much more comfortably on top of #82 (defer-signalr), which would
take this combined to ~756 KB.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(viz): tighten overlay keybind + align CSS with design tokens

Address Gemini review on PR #83:

- Keybind: extend the input-bail list to cover SELECT (the operator
  may type 'i' to jump-search options), and require no shift key
  (uppercase 'I' shouldn't toggle a dev panel from within prose
  typed elsewhere).
- CSS: replace `--fg` / `--muted` with the project's canonical
  `--text` / `--text-muted` (defined in `:root` lines 18-36); fix the
  `--warning` fallback to the palette colour `#d29922`.
- Add `body.investor-mode .sensor-stats-overlay { display: none }` so
  the panel disappears during cinematic recordings — matches the
  visibility rule for the event log and telemetry strip.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant