Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizes type_engine.insert to be done inside if. #5254

Merged
merged 2 commits into from
Nov 5, 2023

Conversation

esdrubal
Copy link
Contributor

@esdrubal esdrubal commented Nov 3, 2023

Description

check_if_trait_constraints_are_satisfied_for_type was inserting a TypeInfo::Custom for every trait impl every time it was called.

This change moves the insertion after the unify check has passed.

This optimization reduces the size of the type engine from 205665 to 138725 while compiling /should_pass/language/supertraits which uses std lib.

The overall improvement is 32.5% in size.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

`check_if_trait_constraints_are_satisfied_for_type` was inserting a `TypeInfo::Custom`
for every trait impl every time it was called.

This change moves the insertion to be done after the unify check has passed.

This optimization reduces the number of size of the type engine from
205665 to 138725 while compiling `/should_pass/language/supertraits` which uses std lib.
The overall improvement is 32.5% less size.
@esdrubal esdrubal added the compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen label Nov 3, 2023
@esdrubal esdrubal self-assigned this Nov 3, 2023
@esdrubal esdrubal requested a review from a team November 3, 2023 13:32
@JoshuaBatty JoshuaBatty requested a review from a team November 5, 2023 11:20
@tritao tritao merged commit 84f6c75 into master Nov 5, 2023
31 checks passed
@tritao tritao deleted the esdrubal/type_engine_insert_optimization branch November 5, 2023 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants