perf(diagnostics): reuse redaction and directory work per scope - #2056
Merged
Conversation
Flushed entries were already fully redacted at emit time; re-running redactDiagnosticData over them at flush is idempotent-but-wasted work, so flush now repeats only the caller-declared value replacement (keeping the property that literals registered between emit and flush are still scrubbed). The sorted sensitive-value list is cached per scope and invalidated on registration instead of being re-sorted per call, and appendDiagnosticLine ensures each log directory once instead of once per appended line.
Data payloads are redacted once at emit time; the flush pass repeats only caller-declared literal replacement so late registrations still win. State explicitly that metadata fields are generated identifiers/internal phase names and are no longer re-normalized at flush, and drop the false claim that replacement output stays length-bounded. Also collapse trivial declarations to bring the module back under the 300-line target.
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
Redact structured event data once at emit time, reuse sorted redaction literals within a diagnostics scope, and memoize ensured log directories per scope.
The scope boundary remains explicit: a new diagnostics scope recreates a deleted log directory rather than inheriting stale process-global state. This is the diagnostics-only slice extracted from #2051.
Validation
pnpm check:affected --run— 593 files / 4,307 tests passed; format, lint, typecheck, layering, Fallow, and build passed.