Skip to content

Speed up union subset checks by scanning sorted constituents - #64964

Open
Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:andarist/sorted-subset-union-scan
Open

Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:andarist/sorted-subset-union-scan

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 22:50
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Oct 25, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 25, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Sparse subset checks now require linear rather than logarithmic search work against large target unions.

1 open issue
What changed in this PR

This PR changes union-subset checking in the native TypeScript checker to use a forward identity scan instead of repeated binary searches.

Changes:

  • Rejects source unions with more members than the target.
  • Searches progressively shorter target slices, relying on sorted union members.
File Description
tsc/​internal/​checker/​relater.go Replaces per-member binary searches with a forward scan and adds a size guard.

Review effort: Balanced

Comment thread tsc/internal/checker/relater.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change preserves subset semantics under the established sorted, deduplicated union invariant, with no blocking issues identified.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@Andarist
Mateusz Burzyński (Andarist) force-pushed the andarist/sorted-subset-union-scan branch from 69739e1 to d2050ae Compare October 26, 2026 07:06
@Andarist Mateusz Burzyński (Andarist) changed the title Check union subsets with a forward identity scan instead of binary searches Speed up union subset checks by scanning sorted constituents Oct 26, 2026
@jakebailey

This comment has been minimized.

@typescript-automation

This comment has been minimized.

@typescript-automation

This comment has been minimized.

@Andarist
Mateusz Burzyński (Andarist) force-pushed the andarist/sorted-subset-union-scan branch from d2050ae to 4c35db3 Compare October 26, 2026 09:22
@jakebailey

This comment has been minimized.

@typescript-automation

This comment has been minimized.

@typescript-automation

This comment has been minimized.

@DanielRosenwasser

This comment has been minimized.

@typescript-automation

This comment has been minimized.

}
return true
}
for _, t := range sourceTypes {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for _, t := range sourceTypes {
for _, t := range sourceTypes {

@typescript-automation

This comment has been minimized.

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) perf test this faster

@typescript-automation

typescript-automation Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this faster ✅ Started ❌ Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey), the perf run you requested failed. You can check the log here.

@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) perf test this faster

@typescript-automation

typescript-automation Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
perf test this faster ✅ Started ❌ Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey), the perf run you requested failed. You can check the log here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

4 participants