Skip to content

[ConstraintSystem] Tweak the generic operator partition heuristic. #35725

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

Merged
merged 1 commit into from
Feb 4, 2021

Conversation

hborla
Copy link
Member

@hborla hborla commented Feb 3, 2021

Before checking if an argument type to an applied disjunction conforms to a known protocol, grab its fixed type. This helps in cases where the argument type is a type variable, but the solver has already bound the type variable to a conforming type, e.g. Array. For example:

protocol P {}

struct S1: P {}
struct S2: P {}

func test(arr1: [S1], arr2: [S2]) -> [P] {
  return arr1.map { $0 as P } + arr2.map { $0 as P }
}

When the solver gets to the generic operator overload partition for +, it knows to attempt the Sequence overloads first because it already knows the result of .map is an array (and map is bound first because there are fewer overloads).

I haven't added a test because this case still doesn't scale well, but this fix mitigates the impact of changing overload binding order from #35025. Cases like this only happened to compile before because the solver happened to attempt Array.+ first.

Resolves: rdar://73892488

disjunction conforms to a known protocol, grab its fixed type.
@hborla hborla requested a review from xedin February 3, 2021 02:52
@hborla
Copy link
Member Author

hborla commented Feb 3, 2021

@swift-ci please test source compatibility

@hborla
Copy link
Member Author

hborla commented Feb 3, 2021

@swift-ci please smoke test compiler performance

@hborla
Copy link
Member Author

hborla commented Feb 3, 2021

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Feb 3, 2021

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2021

Compilation-performance test failed

1 similar comment
@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2021

Compilation-performance test failed

@hborla
Copy link
Member Author

hborla commented Feb 3, 2021

@swift-ci please test source compatibility

@hborla
Copy link
Member Author

hborla commented Feb 3, 2021

@swift-ci please smoke test

@hborla
Copy link
Member Author

hborla commented Feb 3, 2021

@swift-ci please smoke test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2021

Summary for main smoketest

Unexpected test results, excluded stats for Kingfisher, SwiftyTextTable, SourceKittenFramework, Commandant, Yams, ReactiveMapKit, swiftlint, SWXMLHash, Result, ReactiveSwift, Alamofire, ReactiveCocoa, SwiftLintFramework

No regressions above thresholds

Debug

debug brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
time.swift-driver.wall 222.7s 223.9s 1.3s 0.57%

debug detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (4)
name old new delta delta_pct
file-search.NumFrameworkLookups 12,889 12,884 -5 -0.04%
file-search.NumIncluded 61,458 61,374 -84 -0.14%
file-search.NumMultiIncludeFileOptzn 231 231 0 0.0%
file-search.NumSubFrameworkLookups 10,310 10,310 0 0.0%

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
time.swift-driver.wall 291.2s 291.1s -84.5ms -0.03%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (4)
name old new delta delta_pct
file-search.NumFrameworkLookups 12,884 12,884 0 0.0%
file-search.NumIncluded 61,374 61,374 0 0.0%
file-search.NumMultiIncludeFileOptzn 231 231 0 0.0%
file-search.NumSubFrameworkLookups 10,310 10,310 0 0.0%

@hborla
Copy link
Member Author

hborla commented Feb 4, 2021

Looks like a bunch of source compat projects are failing an assertion after the frontend, but no failures in the type checker

@hborla hborla merged commit a25e2cd into swiftlang:main Feb 4, 2021
@hborla hborla deleted the solver-known-arg-type-heuristic branch February 4, 2021 00:11
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