Skip to content

[Constraint solver] Generalize disjunction favoring #23088

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 7 commits into from
Mar 5, 2019

Conversation

DougGregor
Copy link
Member

Clean up the disjunction favoring code to enable favoring of disjunction terms during constraint solving, unifying some of the code around existing utility functions in the constraint solver (getUnboundBindOverload(), getEffectiveOverloadType()) rather than hand-rolled versions.

The call-favoring code was creating a two-level disjunction, when would
then immediately get flattened into a single level. Instead, create a
single-level disjunction directly.
The disjunction partitioning logic was only used for the experimental
designated-types feature, but is generally useful. Unify the code
paths so we always do the partitioning, with only the designated-types
part being enabled/disabled by the flag.
When favoring particular constraints in a disjunction, don't remove
the old disjunction and create a new one---it's just churn in the
constraint system. Instead, favor the constraints that need it.

This technically flips the SR-139 test case from "too complex" to
being fast enough, but it's still fairly slow.
…pe().

The overload-favoring code had a couple of different ways in which it
tried to figure out the parameter lists of a given declaration. Have
those all depend on ConstraintSystem::getEffectiveOverloadType(),
which deals with the various member/non-member cases uniformly.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test performance

@DougGregor
Copy link
Member Author

@swift-ci please smoke test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented Mar 5, 2019

Summary for master smoketest

Unexpected test results, excluded stats for ReactiveCocoa

Regressions found (see below)

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) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 105,127,949,195 105,285,621,556 157,672,361 0.15%
LLVM.NumLLVMBytesOutput 6,138,904 6,138,772 -132 -0.0%
time.swift-driver.wall 14.3s 14.3s 56.1ms 0.39%

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) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 1,110 1,110 0 0.0%
AST.NumLoadedModules 1,038 1,038 0 0.0%
AST.NumTotalClangImportedEntities 4,462 4,462 0 0.0%
AST.NumUsedConformances 886 886 0 0.0%
IRModule.NumIRBasicBlocks 18,028 18,028 0 0.0%
IRModule.NumIRFunctions 10,554 10,554 0 0.0%
IRModule.NumIRGlobals 8,013 8,013 0 0.0%
IRModule.NumIRInsts 312,475 312,475 0 0.0%
IRModule.NumIRValueSymbols 17,630 17,630 0 0.0%
LLVM.NumLLVMBytesOutput 6,138,904 6,138,772 -132 -0.0%
SILModule.NumSILGenFunctions 5,382 5,382 0 0.0%
SILModule.NumSILOptFunctions 7,055 7,055 0 0.0%
Sema.NumConformancesDeserialized 17,297 17,297 0 0.0%
Sema.NumConstraintScopes 40,460 40,484 24 0.06%
Sema.NumDeclsDeserialized 145,811 145,811 0 0.0%
Sema.NumDeclsValidated 11,580 11,580 0 0.0%
Sema.NumFunctionsTypechecked 2,540 2,540 0 0.0%
Sema.NumGenericSignatureBuilders 5,030 5,030 0 0.0%
Sema.NumLazyGenericEnvironments 32,607 32,607 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 2,036 2,040 4 0.2%
Sema.NumLazyIterableDeclContexts 26,629 26,629 0 0.0%
Sema.NumTypesDeserialized 66,236 66,236 0 0.0%
Sema.NumTypesValidated 12,154 12,154 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) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 140,672,743,629 140,631,159,416 -41,584,213 -0.03%
LLVM.NumLLVMBytesOutput 7,128,464 7,128,452 -12 -0.0%
time.swift-driver.wall 26.4s 26.4s 52.4ms 0.2%

release detailed

Regressed (1)
name old new delta delta_pct
Sema.NumLazyGenericEnvironmentsLoaded 130 134 4 3.08% ⛔
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (22)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 402 402 0 0.0%
AST.NumLoadedModules 76 76 0 0.0%
AST.NumTotalClangImportedEntities 2,146 2,146 0 0.0%
AST.NumUsedConformances 890 890 0 0.0%
IRModule.NumIRBasicBlocks 20,921 20,921 0 0.0%
IRModule.NumIRFunctions 10,070 10,070 0 0.0%
IRModule.NumIRGlobals 8,102 8,102 0 0.0%
IRModule.NumIRInsts 220,198 220,198 0 0.0%
IRModule.NumIRValueSymbols 17,316 17,316 0 0.0%
LLVM.NumLLVMBytesOutput 7,128,464 7,128,452 -12 -0.0%
SILModule.NumSILGenFunctions 4,178 4,178 0 0.0%
SILModule.NumSILOptFunctions 5,856 5,856 0 0.0%
Sema.NumConformancesDeserialized 12,445 12,445 0 0.0%
Sema.NumConstraintScopes 39,264 39,288 24 0.06%
Sema.NumDeclsDeserialized 32,249 32,249 0 0.0%
Sema.NumDeclsValidated 7,874 7,874 0 0.0%
Sema.NumFunctionsTypechecked 2,204 2,204 0 0.0%
Sema.NumGenericSignatureBuilders 1,718 1,718 0 0.0%
Sema.NumLazyGenericEnvironments 6,785 6,785 0 0.0%
Sema.NumLazyIterableDeclContexts 4,203 4,203 0 0.0%
Sema.NumTypesDeserialized 18,066 18,066 0 0.0%
Sema.NumTypesValidated 6,942 6,942 0 0.0%

… solving

Allow constraints to be favored during solving, and unwound after exiting
that particular solver scope. We're not using this yet.
…ation.

Use tryOptimizeGenericDisjunction() as part of simplifying apply
constraints.
@DougGregor DougGregor force-pushed the solver-disjunction-favoring branch from 57f2641 to 20bb077 Compare March 5, 2019 18:31
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor DougGregor merged commit fae2d1b into swiftlang:master Mar 5, 2019
@DougGregor DougGregor deleted the solver-disjunction-favoring branch March 5, 2019 22:42
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.

2 participants