Skip to content

Share borrow-check solves and cache impl and shape lookups - #1619

Merged
sbillig merged 4 commits into
masterfrom
compiler-perf-2
Sep 28, 2026
Merged

sbillig merged 4 commits into
masterfrom
compiler-perf-2

Conversation

@sbillig

@sbillig sbillig commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #1617. More redundant work removed from semantic analysis, found by profiling fe test over the fe_test fixtures.

  • Sealed-marker check: checking whether a blanket impl of a foreign trait is anchored by a sealed marker lowered every impl in the marker's ingot (590 in std). It did this for each of std's 9 blanket impls, on every trait-environment lookup. It now visits only the marker's impls, taken from the raw trait index.
  • One final borrowck solve per instance: the final summary query and the borrow check each built and solved the same body. The summary query (now semantic_borrow_analysis_query) also runs the local conflict/availability check on its solved body, and the check query reuses that result. The check still walks resolved callees itself. Contract summaries and cycle fallbacks don't solve a body, so for those the check still solves on its own, as before.
  • lower_impl_trait_header query: every lookup lowered the header of each candidate impl, and completing the selected candidate lowered it again. The query has fixpoint recovery because the sealed-marker check lowers marker impls eagerly.
  • capability_shape query: borrowck rebuilt the shapes of the same types at every access.

In a profile of the previous head, this work was roughly a fifth of CPU time for the fe_test fixtures. The actual gain hasn't been re-measured yet.

A blanket impl of a foreign trait lowers every impl in the marker's ingot
to decide whether the marker is sealed, and impl headers are relowered on
each trait-environment lookup. Use the raw trait index to visit only impls
whose trait path names the marker; the solver sees no other impls of it.
The final summary and the borrow check each built and solved the same
normalized body in final mode. The summary query now also runs the local
conflict and availability checks on its solved body, and the check query
reuses that result, walking resolved callees as before. Contract summaries
and cycle fallbacks do not solve the body, so the check still solves those
itself.
Borrow checking and transport contracts rebuild the capability shape of
the same types at every access, normalizing and walking every field each
time. Make capability_shape a query.
Every trait-environment lookup lowers the header of each candidate impl,
including every blanket impl, and completing a selected candidate lowers
it again. Make lower_impl_trait_header a query. Its sealed-marker check
lowers marker impls eagerly, so give it fixpoint recovery in case that
re-enters the header.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 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-09-28T20:13:54.691977Z df86060 PR opened
🔒 Security Review ✅ Completed 2026-09-28T20:24:23.401900Z df86060 PR opened
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df86060d30

ℹ️ 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".

Comment thread crates/codegen/src/sonatina/mod.rs Resolved
@sbillig
sbillig merged commit d8178bb into master Sep 28, 2026
9 checks passed
@sbillig
sbillig deleted the compiler-perf-2 branch September 28, 2026 23:59
cburgdorf added a commit that referenced this pull request Sep 30, 2026
Several user-facing changes merged after 26.3 were missing release notes
entries:

- Bugfixes: event ABI `anonymous` flag (#1562), string literal escapes
  (#1563), effect provider identity (#1564), shared calls on non-Copy
  fields (#1581), recursive raw pointer types (#1609).
- Performance: `DynArray::get` for static elements (#1559), constant
  string ABI encoding (#1560), compile-time caching (#1617, #1619, #1621).
- Native backend features: workspaces, native tests and `std::io`
  (#1565), process arguments and CPU timing (#1566), `ByteBuffer`
  (#1580).
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.

1 participant