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

[SR-5669] Latent constraint solver performance bug #48239

Closed
davezarzycki opened this issue Aug 9, 2017 · 7 comments
Closed

[SR-5669] Latent constraint solver performance bug #48239

davezarzycki opened this issue Aug 9, 2017 · 7 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@davezarzycki
Copy link
Collaborator

Previous ID SR-5669
Radar rdar://problem/33810893
Original Reporter @davezarzycki
Type Bug
Status Closed
Resolution Invalid
Environment

ToT swift compiler

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @davezarzycki
Priority Medium

md5: 14220d2507595e65cba8bce015bd322f

Issue Description:

The following code demonstrates a massive performance bug in the constraint solver:

var px : Int = 0
var py : Int = 1
var sx : Int = 0
var sy : Int = 1
// SLOW:
let _ : Double = (px-sx)*(px-sx) + (py-sy)*(py-sy)
// FAST workaround:
let _ : Double = Double((px-sx)*(px-sx) + (py-sy)*(py-sy))
@davezarzycki
Copy link
Collaborator Author

See also: rdar://problem/33806601

@belkadan
Copy link
Contributor

belkadan commented Aug 9, 2017

The "slow" case isn't actually legal Swift code. No implicit conversions from Int to Double.

@aschwaighofer
Copy link
Member

@swift-ci create

@davezarzycki
Copy link
Collaborator Author

Ah, you're right. I'm in the weeds. Sorry.

@rudkx
Copy link
Member

rudkx commented Aug 9, 2017

Yes unfortunately there are many such cases where we go exponential, and often these are cases where things do not type check successfully. I did some work over the last year to try to help this, but it wasn't enabled because it didn't help cases where there were generic versions of the operators, and the standard library now has generic versions of many operators.

You can try to enable it locally with -Xfrontend -propagate-constraints.

It appears to help in this case.

The expectation is that we'll be getting back to doing more performance work and I'll try to get this enabled after ensuring that it doesn't regress any cases.

@davezarzycki
Copy link
Collaborator Author

Thanks for the helpful comment Mark!

@rudkx
Copy link
Member

rudkx commented Aug 9, 2017

Actually it does not help in this case, but does take the original case with the closure and speeds it up enough to no longer be "too complex".

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

4 participants