-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
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.
Is there a simple example where this is a performance win? |
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Replaced by #44438 |
In functions with lots of slots that construct PartialStructs with
lots of fields,
widenreturn
would attempt to repeatedly find aninteresting 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.