Skip to content

Check record labels once per record type - #8799

Merged
cknitt merged 2 commits into
masterfrom
record-label-disambiguation
Oct 12, 2026
Merged

cknitt merged 2 commits into
masterfrom
record-label-disambiguation

Conversation

@cknitt

@cknitt cknitt commented Oct 11, 2026

Copy link
Copy Markdown
Member

When the type of a record expression or pattern isn't known from context, the type checker narrows the candidate labels for each field using the record's other fields (Typecore.disambiguate_label_by_ids). For every field and every candidate, it built a hash table of all the labels of the candidate's record type and looked up every field name in it. That is quadratic in the number of fields.

Whether a candidate fits only depends on its record type (the lbl_all array its labels share), so the checks are now done once per record type for the whole expression or pattern.

Untyped record with 2,400 fields Before After
Record literal 1.1s 127ms
Record pattern 1.18s 208ms

Record patterns still grow somewhat faster than linearly; the remaining cost is in the pattern-match checks, not in label disambiguation.

No generated output or error message changes.

🤖 Generated with Claude Code

@cknitt
cknitt added this pull request to stack #8802 October 11, 2026 19:32
@cknitt

cknitt commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T19:43:33.410330Z 819a9a4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.58%. Comparing base (f30bea4) to head (3296593).

Files with missing lines Patch % Lines
compiler/ml/typecore.ml 94.11% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8799   +/-   ##
=======================================
  Coverage   80.58%   80.58%           
=======================================
  Files         447      447           
  Lines       61681    61689    +8     
=======================================
+ Hits        49704    49712    +8     
  Misses      11977    11977           
Files with missing lines Coverage Δ
compiler/ml/typecore.ml 86.50% <94.11%> (+0.04%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new

pkg-pr-new Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript@8799

@rescript/belt

npm i https://pkg.pr.new/@rescript/belt@8799

@rescript/darwin-arm64

npm i https://pkg.pr.new/@rescript/darwin-arm64@8799

@rescript/darwin-x64

npm i https://pkg.pr.new/@rescript/darwin-x64@8799

@rescript/linux-arm64

npm i https://pkg.pr.new/@rescript/linux-arm64@8799

@rescript/linux-x64

npm i https://pkg.pr.new/@rescript/linux-x64@8799

@rescript/runtime

npm i https://pkg.pr.new/@rescript/runtime@8799

@rescript/win32-x64

npm i https://pkg.pr.new/@rescript/win32-x64@8799

commit: 3296593

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 819a9a488f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cknitt
cknitt requested a review from cristianoc October 11, 2026 19:51
cknitt and others added 2 commits October 11, 2026 21:51
Record expressions and patterns without a known type checked every field
against all labels of each candidate record type, which is quadratic in the
number of fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Christoph Knittel <ck@cca.io>
@cknitt
cknitt force-pushed the record-label-disambiguation branch from 819a9a4 to 3296593 Compare October 11, 2026 19:51
@github-actions

Copy link
Copy Markdown

@cknitt
cknitt merged commit 78e29c1 into master Oct 12, 2026
24 checks passed
@cknitt
cknitt deleted the record-label-disambiguation branch October 12, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants