Skip to content

Workbench Profiler time-window single-source-of-truth refactor (closes #345) - #346

Merged
nockawa merged 2 commits into
mainfrom
feature/345-profiler-time-window-refactor
May 12, 2026
Merged

nockawa merged 2 commits into
mainfrom
feature/345-profiler-time-window-refactor

Conversation

@nockawa

@nockawa nockawa commented May 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Refactor of the Workbench profiler time-window architecture per claude/design/Apps/Workbench/profiler-time-window-refactor.md. Eliminates the synchronous pan/zoom fan-out that caused UI judder, collapses two redundant stores into one canonical source of truth, deletes the selectionBridges indirection, simplifies live mode, and removes three now-redundant per-panel debounces.

Also bundled: ChunksPerWorker scheduler knob + small Workbench UI fixes (separate commit on the branch).

Architectural changes

  • Two-slot split in useProfilerViewStore — transientViewRange (in-flight, written on every wheel notch / drag pixel / rAF zoom frame) + committed viewRange (debounced, read by every cross-panel consumer). Debounce window is useOptionsStore.options.profiler.viewRangeDebounceMs.
  • Deleted useSelectionStore.time and useSelectionStore.focusTick — every consumer (SystemDag, CriticalPath, DataFlow, AccessMatrix, SystemDagToolbar, selectionUrlSync) reads useProfilerViewStore.viewRange directly. CriticalPath's display tick collapses to dominantTickInRange(viewRange) with midpoint fallback.
  • Deleted selectionBridges.ts and its tests — the three remaining cross-store mirrors inline into store setter actions.
  • Deleted live-follow mode — useProfilerSessionStore.liveFollowActive, setLiveFollowActive, useProfilerViewStore.liveFollowWindowUs all removed. Attach pins viewport to first tick; subsequent ticks do not auto-move.
  • Removed redundant per-panel debounces — useProfilerStatsWriter's internal 150 ms gone; DataFlow/AccessMatrix dropped their liveTime gate (kept latestTickNumber for live-stream burst coalescing).
  • viewRangeDebounceMs added to WorkbenchOptions — default 150 ms, clamped [0, 5000], exposed in the Profiler options form. 0 = synchronous commit.

Behaviour changes

  • Clicking a tick in TickOverview / a span or phase in TimeArea now snaps the viewport to that tick's bounds (was: only updated selection / CP overlay).
  • Live-follow is gone. Attach pins to first tick on arrival and stays until user pans/zooms.

Bundled (separate commit)

  • ChunksPerWorker(float) knob on SystemBuilder — caps chunk count at round(WorkerCount × factor) to oversubscribe parallel dispatch for systems whose worker efficiency falls below saturation. Default 1.0 = no change. AntUpdate set to 2.0f to address its 45% worker efficiency.
  • Critical bug fix in TyphonRuntime: per-worker pool arrays (_partitionViews, _tierRangeViews) were sized to WorkerCount but indexed by chunkIndex — silently threw IndexOutOfRangeException once ChunksPerWorker > 1. Fixed by indexing with workerId. Regression test Oversubscribed_AllEntitiesAreVisited added.
  • Workbench: hidden two misleading per-tick wrapping spans (Scheduler.System.Archetype kind 245, and per-tick Query.Plan kind 189 with OwnerSystemIdx) from worker lanes — they cover all-workers ranges but were emitted from the completer worker and appeared on its lane.

Test plan

  • Vitest suite green (607 tests)
  • TS strict check clean
  • New tests: useProfilerViewStore.transient.test.ts, useProfilerViewStore.migration.test.ts (v3 → v4 persisted-state migration), ChunksPerWorkerTests, ScheduleValidationTests additions
  • selectionBridges.test.ts deleted; URL-sync tests updated to round-trip via viewRange
  • Manual: confirm 60 Hz pan/zoom fluidity with SystemDag, CriticalPath, DataFlow, AccessMatrix all open; debounce knob effective at 0 ms (sync) and 300+ ms

Closes #345

🤖 Generated with Claude Code

@nockawa
nockawa merged commit 92e69e4 into main May 12, 2026
6 checks passed
@nockawa
nockawa deleted the feature/345-profiler-time-window-refactor branch May 12, 2026 14:19
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.

Workbench Profiler: time-window single-source-of-truth refactor (fluidity fix)

1 participant