Repository navigation
Count intersection property names with a plain map and slice - #64876
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Open
Jake Bailey (jakebailey) wants to merge 1 commit into
Jake Bailey (jakebailey) wants to merge 1 commit into
Conversation
Deciding whether an intersection reduces to never counts how many
constituents declare each property name. The ordered map used for
this is a general-purpose structure that does more bookkeeping per
operation than this hot path needs, and each property costs a lookup
and an assignment. On mui-docs this shows up as a few percent of
single-checker time.
Count into a slice of entries indexed by a plain string map instead.
The slice keeps first-occurrence order for the reduction check, and
the first constituent's names are inserted without a lookup since
property names are already unique within a type.
│ old │ new │
│ sec/op │ sec/op vs base │
Tsc/bluesky 3.179 ± 1% 3.133 ± 1% -1.45% (p=0.039 n=6)
Tsc/sentry 12.90 ± 7% 12.77 ± 17% ~ (p=0.818 n=6)
Tsc/t3code-server 16.85 ± 3% 16.80 ± 3% ~ (p=0.937 n=6)
Tsc/mui-docs 8.536 ± 3% 8.152 ± 1% -4.50% (p=0.002 n=6)
geomean 8.763 8.604 -1.81%
│ old │ new │
│ rss-B │ rss-B vs base │
Tsc/bluesky 1.439Gi ± 2% 1.417Gi ± 1% ~ (p=0.093 n=6)
Tsc/sentry 4.566Gi ± 4% 4.504Gi ± 4% ~ (p=0.937 n=6)
Tsc/t3code-server 4.488Gi ± 5% 4.344Gi ± 9% ~ (p=0.485 n=6)
Tsc/mui-docs 3.535Gi ± 4% 3.391Gi ± 4% ~ (p=0.065 n=6)
geomean 3.195Gi 3.114Gi -2.55%
│ old │ new │
│ heap-B │ heap-B vs base │
Tsc/bluesky 1.153Gi ± 0% 1.152Gi ± 0% ~ (p=0.394 n=6)
Tsc/sentry 3.620Gi ± 0% 3.622Gi ± 0% ~ (p=0.485 n=6)
Tsc/t3code-server 3.761Gi ± 0% 3.762Gi ± 0% ~ (p=0.310 n=6)
Tsc/mui-docs 2.641Gi ± 0% 2.641Gi ± 0% ~ (p=0.818 n=6)
geomean 2.537Gi 2.537Gi +0.01%
Member
Author
|
TypeScript Bot (@typescript-bot) perf test this faster |
Contributor
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in this localized refactor; automated validation was not run.
1 open issue
What changed in this PR
Optimizes property counting when the checker determines whether an intersection reduces to never, while preserving first-occurrence order.
Changes:
- Replaces the ordered map with a name-to-index map and count slice.
- Skips lookups for the first constituent’s properties.
- Updates counting and workspace-reuse tests.
| File | Description |
|---|---|
| tsc/internal/checker/utilities.go | Implements map-and-slice property counts. |
| tsc/internal/checker/types_test.go | Adapts counting and reuse assertions. |
| tsc/internal/checker/checker.go | Uses the new counting operations during intersection reduction. |
Review effort: Balanced
Comment on lines
+937
to
+938
| entries []propertyCount | ||
| indices map[string]int32 |
Contributor
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This branch has not been deployed
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.

This will conflict with #64815 to some extent