[diagnostics] add type-trace category + --diagnostics CLI flag#657
Merged
[diagnostics] add type-trace category + --diagnostics CLI flag#657
Conversation
Contributor
Benchmark Results (Linux x86-64)
CLI Tool Benchmarks
|
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.
Before
Codegen type-tracking side-effects were opaque. Past refactors toward a sema-driven typed-AST stalled because we didn't know which callers actually read which types, or whether the pre-codegen annotator was even populating the cache with useful data.
After
Compiler supports
--diagnostics=type-trace [--diagnostics-out=<path>]onbuild,run, andirsubcommands. Produces a JSONL stream of everysetVariableType/getVariableType/resolveExpressionTypeRichevent with compact callsite stacks. Off by default, zero cost when off.Description
src/diagnostics/module:sink.ts(in-memory buffer +fs.writeFileSyncflush on exit),categories.ts(CSV parser + known list),tracers.ts(traceTypeSet/Get/Rich + per-category enable flags)chad-node.tsandchad-native.ts, enable sink + category pre-compilebase-generator.ts,generator-context.ts,type-inference.ts— each trace call is a one-line early-return when offscripts/analyze-diagnostics.cjsgroups events by callsite, reports orphan-set ratios, top rich-query sourcesMotivation
Audit run in a scratch branch revealed that
semantic/type-annotator.jsalready fires 44,301 rich-resolver queries per compile with zero null results — the pre-codegen cache is fully populated. TheisStableExprTypegate refuses to serve most of it. 64.7% ofsetVariableTypecalls are orphans (no subsequent read). These findings reshape the refactor path in #640 — future PRs can cite numbers from this trace instead of guessing. See #640 for the data-driven plan this enables.