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-7525] -solver-memory-threshold no longer performs expected memory check in many cases #50067

Closed
swift-ci opened this issue Apr 24, 2018 · 8 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7525
Radar rdar://problem/40952582
Original Reporter Samanta (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 9.3 + Swift 4.1

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

md5: 7784df6ff9a74c6acba95a1b9ce78f77

Issue Description:

We use -solver-memory-threshold as a way to keep compile times low in our large codebase in a consistent manner (as opposed to -warn-long-function-bodies which varies from machine to machine).

With Swift 4.1, we notice the warnings no longer seem to appear. I suspect it's due to the changes introduced in 5f2aeec.

My guess is that this clause:

// If we haven't explored a relatively large number of possibilities
// yet, continue.
if (CountScopes <= 16 * 1024)
    return false; 

causes an early exit from the getExpressionTooComplex() and it never gets to the end of the fucntion, where the memory threshold check is done.

It would be good to move the memory check early so that it's still honored for those users who do wish to limit the complexity of expressions allowed in their codebase.

If this is not reasonable, then perhaps we could allow user to tune the hard-coded 16K number in the number of scopes check in the code snippet above.

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented May 1, 2018

cc @rudkx

@swift-ci
Copy link
Collaborator Author

swift-ci commented May 1, 2018

Comment by Rudro (JIRA)

Forgot to mention that repro steps are easy.

Put some simple swift code into Test.swift and run

swiftc -solver-memory-threshold 1 ~/Test.swift 

Given that I'm setting the threshold to 1 byte, I would expect even the most simple expressions to fail, but they appear to pass with Swift 4.1.

$ swiftc --version
Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)

@slavapestov
Copy link
Member

@swift-ci create

1 similar comment
@slavapestov
Copy link
Member

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Jun 9, 2018

PR for master: #17076

@rudkx
Copy link
Member

rudkx commented Jun 9, 2018

Merged: 049c3f0

@rudkx
Copy link
Member

rudkx commented Jun 9, 2018

PR for 4.2: #17081

@rudkx
Copy link
Member

rudkx commented Jun 9, 2018

Merged to 4.2: e594359

@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

3 participants