Repository navigation
perf(apiStabilityLeak): reuse one analysis per file - #870
Merged
Merged
Conversation
checkApiStabilityLeaks allocated a fresh ApiStabilitySession for every export, and each one built and regrew its maps and work queues. The rule now keeps one session per file and calls Reset before each export. apiStabilityAnalysis.reset clears every per-export map, truncates the settle and publish slices, resets the settle scope and zeroes the budgets and the materialization epoch, keeping the allocated capacity. A shared-cache hit in typeSurface and signatureSurface is recorded in the session map and the settle order without being queued for publication, since publication would skip it anyway. publishTypeSurface and publishSignatureSurface allocate the snapshot's findings map only for the first retained finding. Effect 4.0.5 workload (7f524e25), every rule executing, packages/effect, 5 interleaved profiled runs per side, medians: checkApiStabilityLeaks alloc_space 252 MB -> 140 MB rulerunner.Run alloc_space 754 MB -> 633 MB checkApiStabilityLeaks CPU 0.98 s -> 0.92 s (ranges overlap) Diagnostic equivalence: a dump of every rule-returned diagnostic from a clean build of the whole workload is byte-identical on both sides (1,404 apiStabilityLeak diagnostics on each). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Effect perf vs stock tsgo: 2 flagged rows
Details
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Why
apiStabilityLeakbuilt a freshApiStabilitySessionfor every export of a file, and each one allocated and regrew its maps and work queues. Onpackages/effectthe rule allocated about 250 MB this way. The rule now keeps one session per file and resets it before each export.What changed
ApiStabilitySession.Resetcalls a newapiStabilityAnalysis.reset. That clears every per-export map, truncates the settle and publish slices, resets the settle scope and zeroes the budgets and the materialization epoch. The allocated capacity is kept.typeSurfaceandsignatureSurfacegoes into the session map and the settle order, but not into the publication queue. Publication skipped it anyway.publishTypeSurfaceandpublishSignatureSurfaceallocate a snapshot's findings map only for the first retained finding.Scope
The settle scoping and the lazy surface findings maps from #862 and #863 are unchanged. A future per-export field on
apiStabilityAnalysismust also be cleared inreset. The new test compares a reset analysis field by field with a fresh one, and it fails on a field kind it does not know.Blast radius
Only
apiStabilityLeakuses the session, and the rule is off by default. A missed field inresetwould leak one export's results into the next export. The field-by-field test and the byte-identical diagnostic dump guard against that.Verification
packages/effect:checkApiStabilityLeaksallocation 252 MB → 140 MB (median of 5 interleaved profiled runs per side, ranges disjoint). Rule CPU moved 0.98 s → 0.92 s, inside the noise.apiStabilityLeakdiagnostics each.api_stability_reset_test.gocheck three things: a reset analysis equals a fresh one, a stale budget or result does not reach the next export, and a cache hit is not queued for publication again. Mutants that drop aclearor theworkreset, or that re-queue the hit, all fail them.go test ./internal/...,pnpm lintandpnpm checkpass.pnpm testdid not run.🤖 Generated with Claude Code