Skip to content

Profiler Source Attribution v2 — file:line for every span (#302) - #303

Merged
nockawa merged 1 commit into
mainfrom
freature/go-to-source
May 5, 2026
Merged

nockawa merged 1 commit into
mainfrom
freature/go-to-source

Conversation

@nockawa

@nockawa nockawa commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #302.

Summary

  • Per-span file:line · method in the Workbench detail panel, plus one-click "Open in editor" (VS Code / Cursor / Rider / Visual Studio / Custom) and a syntax-highlighted inline preview.
  • Capture is build-time: SourceLocationGenerator (Roslyn IIncrementalGenerator + C# 14 interceptors) discovers every TyphonEvent.Begin* call site, sorts by (file, line, column), assigns deterministic ushort site IDs, and emits per-call-site [InterceptsLocation] wrappers that thread a literal ushort through MakeHeader — zero hot-path cost.
  • System attribution: DagBuilder registration resolves each system delegate's PDB sequence points (with a <Unknown>-mono fallback that searches by AssemblyName + version), so chunk spans (e.g. AntHill MoveAll, FoodDetect) get the same source row.
  • Wire format: SpanFlagsHasSourceLocation + 2-byte u16 SourceLocationId after the optional trace context. TraceFileHeader v4→v5 with new FileTableOffset / SourceLocationManifestOffset trailer pointers; reader is backward-compatible with v4 (treats absent fields as "no manifest").
  • Manifest shipped via the trace-file trailer and the live TCP init handshake; client useSourceLocationStore resolves both static call-site IDs and synthesized system IDs (0x8000 | systemIndex) through the same lookup.
  • Workbench Options system: file-backed JSON + FileSystemWatcher hot-reload + SSE OptionsChangedStream; OptionsStore uses [LoggerMessage] partial methods and a separate _writeLock so disk I/O doesn't block readers.
  • New EditorLauncher with per-(EditorKind, OS) adapters, ProfilerSourceController with workspace-root auto-detection and a path-traversal guard that allows already-absolute PDB paths.
  • Detail-pane Source row + "Show Source for Current Span" palette command + Ctrl+double-click on span/chunk bars to open editor + Source Preview panel auto-follows selection when open.

Test plan

  • dotnet build Typhon.slnx -c Debug — 0 errors
  • dotnet test test/Typhon.Engine.Tests/... — Profiler-scoped fixtures all green (517 tests)
  • dotnet test test/Typhon.Workbench.Tests/... — 4 new fixtures (OptionsControllerTests, SystemControllerTests, EditorLauncherTests, ProfilerSourceControllerTests) all green; existing fixtures unaffected
  • Live attach + recorded trace open: BTreeInsert spans show file:line · method, AntHill MoveAll chunk shows its system source, "Open in editor" opens Rider on Windows, "Show inline" renders ±20 lines highlighted
  • BenchmarkDotNet: per-emission overhead vs baseline is unmeasurable (literal ushort move)
  • macOS QA on EditorLauncher (deferred — no Mac in the loop this pass)

@nockawa nockawa self-assigned this May 5, 2026
@nockawa
nockawa merged commit 35405d3 into main May 5, 2026
6 checks passed
@nockawa
nockawa deleted the freature/go-to-source branch May 5, 2026 13:20
@nockawa nockawa moved this to Done in Typhon dev May 17, 2026
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.

Profiler Source Attribution (v2) — file:line for every span, with editor handoff

1 participant