Repository navigation
Refactor TyphonEvent emission: header + source generator + codec (#294) - #295
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #294. Eliminates ~7,800 LOC of mechanical boilerplate across ~99 typed-event ref structs by consolidating the seven prologue fields into a
TraceSpanHeadersub-struct and generating the per-kind boilerplate (Kind constant, Header field, optional property accessors, Dispose, BeginX factory, andComputeSize/EncodeTofor 89/99 events) via a Roslyn source generator. Wire format is unchanged byte-for-byte.What landed
TraceSpanHeader. Seven prologue fields (ThreadSlot,StartTimestamp,SpanId,ParentSpanId,PreviousSpanId,TraceIdHi,TraceIdLo) consolidated into one embedded struct on every event ref struct. Wire-neutral.Typhon.Generators.TraceEventGenerator. Roslyn incremental generator emitsKind,Header,_optMask, optional property setters,Dispose, and theTyphonEvent.BeginX(...)factories from[TraceEvent]/[BeginParam]/[Optional]attributes synthesized viaRegisterPostInitializationOutput(no annotations DLL).ComputeSizeandEncodeTodirectly for 89/99 events (EmitEncoder = true). 10 escape-hatches keep hand-written codec calls: 4 Transaction family (kind-conditionalcomponentTypeId/walLsn-in-slot reuse), 5 PageCache family (codec always emits anoptMaskbyte even with no optionals; PageCacheFlush reuses thefilePageIndexslot), andEcsQueryAny(Foundbool sharesResultCount's 4-byte slot).<Codec>.Encode<X>(buf, ...)to<Struct>.EncodeTo(buf, ...).[Obsolete]codec encoder methods deleted across 29 codec files (zero callers post-migration). 6 LIVE codec methods retained for the escape-hatches;NamedSpanEventCodec.Encoderetained as the variable-length-payload escape-hatch.BeginFactoryParameterTests,SingleOptionalSetTestscover the generator-emitted contract; off-path BenchmarkDotNet regression benchmark (TyphonEventOffPathBenchmarks) confirms zero allocation + 1.5–2.2 ns/call delta vsEmptyMethod— committed baseline attest/Typhon.Benchmark/TyphonEventOffPathBenchmarks-baseline.md.Numbers
TyphonEvent.cs: 5,214 → 3,370 (−1,844)Profiler/Events/: 2,566 → 1,405 (−1,161)src/Typhon.Profiler/*Codec.cs: 77 method bodies deleted (~−2,400 LOC)TraceSpanHeader.cs(+50),TraceEventGenerator.cs(+738)Test plan
dotnet build src/Typhon.Engine— 0 warnings, 0 errorsdotnet test --filter ~Typhon.Engine.Tests.Profiler— 492/492 pass (~660 ms)dotnet test Typhon.slnx— 3,786 engine tests run; 2 unrelated pre-existing flakes (OlcBTreeTests.Remove_MixedInsertAndRemove_NoCorruptionBTree concurrent-remove consistency check;CheckerboardTests.Checkerboard_NoTierFilter_StillSplitstick-callback timing). Neither is touched by this branch.EmptyMethod— seetest/Typhon.Benchmark/TyphonEventOffPathBenchmarks-baseline.md.Related docs
claude/design/observability/typhon-event-emission-refactor.mdclaude/design/observability/typhon-profiler.md§4 banner removed, §5 updated to describe the source-generator–driven model and the 10 escape-hatches.🤖 Generated with Claude Code