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

Avoid O(N^2) behavior in widenreturn #44437

Closed
wants to merge 1 commit into from
Closed

Avoid O(N^2) behavior in widenreturn #44437

wants to merge 1 commit into from

Conversation

Keno
Copy link
Member

@Keno Keno commented Mar 4, 2022

In functions with lots of slots that construct PartialStructs with
lots of fields, widenreturn would attempt to repeatedly find an
interesting slot for Interconditional to use. This is unnecessary,
because the slot selected does not depend on the value of the
PartialStruct field. Memoize this computation and only do it once
per return statement.

In functions with lots of slots that construct PartialStructs with
lots of fields, `widenreturn` would attempt to repeatedly find an
interesting slot for Interconditional to use. This is unnecessary,
because the slot selected does not depend on the value of the
PartialStruct field. Memoize this computation and only do it once
per return statement.
@oscardssmith
Copy link
Member

Is there a simple example where this is a performance win?

@Keno
Copy link
Member Author

Keno commented Mar 4, 2022

I've been working through all the pathologies of this testcase: https://gist.github.com/Keno/5587fbfe89bff96c863c8eeb1477defa. This was one of them.

@@ -2075,7 +2086,7 @@ function widenreturn(@nospecialize(rt), @nospecialize(bestguess), nslots::Int, s
local anyrefine = false
for i in 1:length(fields)
a = fields[i]
a = isvarargtype(a) ? a : widenreturn(a, bestguess, nslots, slottypes, changes)
a = isvarargtype(a) ? a : widenreturn(a, bestguess, nslots, slottypes, changes, interconditional_slot)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Fields are prohibited from containing Conditional/InterConditional values

Copy link
Member Author

@Keno Keno Mar 4, 2022

Choose a reason for hiding this comment

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

Then the code that is here now is wrong, because it likes to add them.

Keno added a commit that referenced this pull request Mar 4, 2022
Keno added a commit that referenced this pull request Mar 4, 2022
@Keno
Copy link
Member Author

Keno commented Mar 4, 2022

Replaced by #44438

@Keno Keno closed this Mar 4, 2022
@aviatesk aviatesk deleted the kf/intercondn2 branch March 4, 2022 06:14
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.

3 participants