Skip to content

Off-CPU sample classification (#364) + Workbench evolutions (#365) - #366

Merged
nockawa merged 2 commits into
mainfrom
feature/364-off-cpu-sampling
May 20, 2026
Merged

nockawa merged 2 commits into
mainfrom
feature/364-off-cpu-sampling

Conversation

@nockawa

@nockawa nockawa commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Two independent commits landing together on this branch — each maps to its own tracking issue.

Commit 1 — Solve #365 (Workbench evolutions)

Eight independent Workbench-side buckets that accumulated on this branch alongside the #364 work. Full per-bucket detail and suggested PR sub-split is in #365; summary:

  1. HTTP 202 "session building" contract — schema + query-catalog endpoints surface a transient-build state as 202 Accepted + Retry-After; client envelopes 202 and hooks poll quietly via refetchInterval. Replaces the old "Query failed" log spam during fresh-trace cache builds.
  2. silenceErrors opt-out on the global query/mutation cache logger (bool or predicate via meta.silenceErrors); new FetchError carrying parsed ProblemDetails. Schema hooks silence URL-restored 404s; RecentFiles silences fs/stat 404s.
  3. Roslyn-based Source Preview — Microsoft.CodeAnalysis.CSharp 5.3.0 replaces brace-counting so braces inside strings/comments/interpolations no longer truncate the cropped method block. New View menu entry + command palette entry + surfacePanel helper that expands collapsed edge groups.
  4. "View in Call Tree" with method-drill — TimeArea + Detail context menus scope the Call Tree and re-root it at the emitting method (§8.2). Call Tree breadcrumb now stacks full view state (scope + frameRoot).
  5. Critical Path drag-to-zoom + local nav history — 800 ms ease-out tween (matches TimeArea), 50-entry CP-local back/forward stack, wheel-burst debounce, label-size gated occupancy %.
  6. System DAG fitView readiness gate — monotonic fitToken consumed by <FitController/> that waits for xyflow readiness; fixes fits-to-off-screen-targets on dockview hidden-tab mount. Middle-click fit.
  7. Dockview theme polish — --wb-dv-header / --wb-dv-selected-tab color-mix shades so the panel header and the active view are visually identifiable in both themes.
  8. DbMap context-menu portal fix — portaled to body, pointerdown instead of mousedown, z-index 10000.

Commit 2 — Solve #364 (Off-CPU sample classification) + ClaimSlotInCell optim

#364 — Off-CPU sample classification

§8.7 of the CPU sampling integration design. A wall-clock CPU sample stack is no longer trusted as on-CPU evidence by itself — each sample is classified by joining it against GC-suspension intervals and EtwSchedulingPump context-switch slices:

  • ThreadScheduling default coupled to CpuSampling — enabling CPU sampling pulls scheduling capture on too (the classifier needs the slices). An explicit Profiler:Runtime:ThreadScheduling:Enabled still wins.
  • GC-safepoint-poll leaves dropped in CpuSampleParser — a sample whose leaf is Thread.PollGC / <PollGC>g__PollGCWorker|NN_N is the cost of being sampled, not program execution. Memoised per-CodeAddressIndex.
  • SampleClassifier (Workbench-side) labels each sample on-CPU / voluntary-wait / involuntary-stall (GC / Scheduler / Paging). Lazy per-session, best-effort — degrades to the SampleType proxy when context-switch data is absent.
  • CallTreeFolder §8.7 integration — voluntary waits fold per-method in wall-clock but drop in on-CPU view; involuntary stalls never fold per-method, they collapse into synthetic aggregate nodes [GC suspension] / [Preempted] / [Paging] hung off the root, with negative FrameIds (-2, -3, -4) to mark them synthetic.
  • ClassificationAvailable flag flows through the DTO so the panel labels its on-CPU view "Thread time" in degraded mode.

ClaimSlotInCell optim (piggy-backed)

Discovered while profiling for #364: parallel-fence migration releases were resetting the source cell's scan cursor on every release, thrashing it and re-introducing O(M²) re-scans during ExecuteMigrations. Fix:

  • Two-phase claim scan — phase 1 forward from the cursor (O(1) amortized for append-only spawn), phase 2 self-heals stale-high cursors by scanning [0, scanStart). Cursor becomes a pure hint; staleness costs a redundant scan, never a missed free slot.
  • DecrementCellEntityCountOnRelease(resetCursor:) — serial releases (Transaction.Destroy) reset the cursor for immediate reuse; parallel-fence releases skip the reset (would zero cursors of cells other workers are actively claiming into → cursor thrash + false sharing).
  • CellClusterPool.SetScanCursor — backwards-capable cursor write for the phase-2 reclaim path. Safe as a plain write because every cell's cursor is single-writer across all paths.

Tests cover the migration-release cursor invariant and the phase-2 reclaim path.


Closes #364
Closes #365

@nockawa
nockawa merged commit e2eb32e into main May 20, 2026
6 checks passed
@nockawa
nockawa deleted the feature/364-off-cpu-sampling branch May 20, 2026 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant