Skip to content

Profiler: typed events + viewer Phase 4 + cache v8 (#243) - #245

Merged
nockawa merged 4 commits into
mainfrom
feature/243-tracy-profiler
Apr 19, 2026
Merged

nockawa merged 4 commits into
mainfrom
feature/243-tracy-profiler

Conversation

@nockawa

@nockawa nockawa commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces the scheduler-scoped profiler with a general-purpose typed-event system: 256 per-thread SPSC slots, dedicated consumer, pluggable exporters (FileExporter, TcpExporter), JIT-gated via static readonly flags. 37 typed event kinds covering BTree / Tx / ECS / PageCache (with async-completion correlation) / WAL / Checkpoint / Statistics / ClusterMigration / NamedSpan / scheduler internals / GC / MemoryAllocEvent / PerTickSnapshot / ThreadInfo. Migrated 25 call sites; deleted IRuntimeInspector + TraceEventCaptureBase + TraceFileInspector + TcpStreamInspector + DagScheduler.Inspector.cs.
  • Scalable web viewer (Phase 1–4): Preact SPA + Canvas Gantt, sidecar cache .typhon-trace-cache (ChunkerVersion = 8), chunk-based lazy loading, binary LZ4 transport through a 1–4 Web Worker pool with per-slot failure isolation, OPFS persistent chunk cache (1 GB/trace, 5 GB global), live SSE streaming, FlameGraph tab fed by .nettrace, gauge region with 5 tracks (Memory / Page Cache / WAL / Tx+UoW / GC) and per-sub-row tooltips.
  • Intra-tick chunk splitting (cache v8): ChunkManifestEntry.Flags bit 0 = IsContinuation. Pathologically dense ticks split across multiple chunks; client merges transparently via mergeTickData chain-fold at assembly time. Gold-standard correctness test pins byte-identical merge output to single-pass output. Chunk endpoint switched to chunkIdx identity; X-Chunk-Is-Continuation response header plumbed through ChunkBinaryHeaders const class.
  • GC event tracing: dedicated GcEventListener + GcEventQueue + GcIngestionThread (in-process EventPipe on Microsoft-Windows-DotNETRuntime / GCKeyword); emits GcStart (7) / GcEnd (8) / GcSuspension (75). Per-tick gauge snapshot system (GaugeSnapshotEmitter + PerTickSnapshot kind 76 + wire-stable GaugeId registry). MemoryAllocEvent (kind 9) for all PinnedMemoryBlock traffic. ThreadInfo (kind 77) records for slot identity. Each subsystem independently gated by its own TelemetryConfig.Profiler*Active flag.
  • 14 new engine-side Profiler test files + Vitest client suite (chunkDecoder.test.ts, traceModel.test.ts). Design doc rewritten, user manual added, 4 D2 architecture diagrams authored + rendered, README index updated.

Test plan

  • Engine test suite green — 3300+ tests including new Profiler round-trip, SPSC stress, exporter-queue, slot-registry, and intra-tick-split builder tests
  • Vitest suite green — 6 tests including gold-standard merge correctness and isContinuation tick-counter seed invariants
  • IOProfileRunner trace generation + viewer load validated on ioprofile-1k.typhon-trace, ioprofile-2k.typhon-trace, and ioprofile-split-test.typhon-trace (200 K entities in a single tick → 6 continuation chunks)
  • AntHill ProfileRunner captures expected spans across configs
  • npx tsc --noEmit on ClientApp — clean
  • Vite production bundle builds
  • GC capture verified on traces after ProfilerGcTracingActive → events appear in GC track

Resolves #243

nockawa added 4 commits April 17, 2026 12:54
Engine
- GaugeSnapshotEmitter for per-tick memory / page-cache / WAL / tx / GC gauges
- GcEventListener + GcEventQueue + GcIngestionThread (ETW → typed events on a dedicated thread slot, preserves SPSC invariant)
- Remove Volatile.Read/Write on ≤64-bit fields per project rule

Server
- PathGuard on /api/trace/chunk and /api/trace/chunk-binary
- TraceFileCacheConstants.EventCap (50k) + bump CurrentChunkerVersion 7→8
- Cached GC-suspension list on session slot for stable viewer yMax
- ChunkBinaryHeaders const class (single source of truth for header names)

Viewer
- OPFS-backed persistent chunk cache keyed by source fingerprint, with corruption fallback + serialized writes
- Worker pool (1-4 workers, least-busy dispatch) for parallel chunk decode
- Per-call pinned set threaded through loadChunk (fixes cross-call eviction race), per-cache over-budget warning, failed-chunk retry-after map
- Load-epoch guard in open handlers (fixes two-handler trace-switch race)
- AVG_BYTES_PER_EVENT 200→500 to reflect real V8 object overhead
- "Loading ticks…" overlay while a dense chunk decodes

If you want it tighter for a one-line subject + brief body, here's an alternative:

Profiler gauge snapshots + GC ingestion; viewer chunk pipeline hardened

Adds engine-side gauge snapshot subsystem and a dedicated GC event ingestion thread. Hardens the viewer's chunk loading: OPFS persistence with corruption fallback, parallel decode via worker pool, race-safe trace switches, failed-chunk retry suppression, and server-side event-count chunk cap (cache v8).
@nockawa
nockawa merged commit bcd8e52 into main Apr 19, 2026
5 checks passed
@nockawa
nockawa deleted the feature/243-tracy-profiler branch April 19, 2026 17:18
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.

Typed-Event Profiler — general-purpose capture subsystem

1 participant