Skip to content

[Constraint graph] Gathering "all mentions" constraints means all mentions #26691

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

Closed

Conversation

DougGregor
Copy link
Member

When requesting all constraints that mention the given type variable,
use a depth-first search to ensure that we find all mentions, rather
than some subset of them. Fixes rdar://problem/54322807.

We only care about gathering a one-way constraint if (1) the left-hand
side is in the set of type variables we care about now, and (2) the
type variable we started from is in the right-hand side.
…tions.

When requesting all constraints that mention the given type variable,
use a depth-first search to ensure that we find all mentions, rather
than some subset of them. Fixes rdar://problem/54322807.
@DougGregor DougGregor requested a review from xedin August 16, 2019 05:12
@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 test compiler performance

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Only possible side-effect I see is related to isInterestingTypeVar it might be worse adding test-case from #19852 to use suite to make sure that performance doesn't regress.

@xedin
Copy link
Contributor

xedin commented Aug 16, 2019

@swift-ci please smoke test Linux platform

@swift-ci
Copy link
Contributor

Summary for master full

Unexpected test results, excluded stats for RxCocoa, SwifterSwift

Regressions found (see below)

Debug-batch

debug-batch brief

Regressed (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 42,712,391,929,312 43,344,852,093,793 632,460,164,481 1.48% ⛔
time.swift-driver.wall 4352.9s 4451.8s 98.9s 2.27% ⛔
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 1,747,331,742 1,747,330,674 -1,068 -0.0%

debug-batch detailed

Regressed (6)
name old new delta delta_pct
Driver.NumDriverPipePolls 79,966 82,523 2,557 3.2% ⛔
Driver.NumDriverPipeReads 69,870 72,527 2,657 3.8% ⛔
Frontend.NumInstructionsExecuted 42,712,391,929,312 43,344,852,093,793 632,460,164,481 1.48% ⛔
Sema.NumConstraintScopes 24,627,323 29,607,744 4,980,421 20.22% ⛔
Sema.NumConstraintsConsideredForEdgeContraction 73,602,258 117,301,191 43,698,933 59.37% ⛔
Sema.NumLeafScopes 15,947,125 18,961,798 3,014,673 18.9% ⛔
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (139)
name old new delta delta_pct
AST.NumASTBytesAllocated 59,432,249,899 59,220,905,859 -211,344,040 -0.36%
AST.NumDecls 136,758 136,758 0 0.0%
AST.NumDependencies 242,701 242,703 2 0.0%
AST.NumInfixOperators 52,929 52,929 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 313,357 313,357 0 0.0%
AST.NumLocalTypeDecls 241 241 0 0.0%
AST.NumObjCMethods 24,471 24,471 0 0.0%
AST.NumPostfixOperators 23 23 0 0.0%
AST.NumPrecedenceGroups 24,973 24,973 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 189 189 0 0.0%
AST.NumReferencedMemberNames 6,215,547 6,215,556 9 0.0%
AST.NumReferencedTopLevelNames 466,215 466,215 0 0.0%
AST.NumSourceBuffers 384,044 384,044 0 0.0%
AST.NumSourceLines 4,600,569 4,600,569 0 0.0%
AST.NumSourceLinesPerSecond 3,438,467 3,434,263 -4,204 -0.12%
AST.NumTotalClangImportedEntities 5,556,771 5,551,775 -4,996 -0.09%
Driver.ChildrenMaxRSS 192,858,456,064 193,083,465,728 225,009,664 0.12%
Driver.DriverDepCascadingDynamic 0 0 0 0.0%
Driver.DriverDepCascadingExternal 0 0 0 0.0%
Driver.DriverDepCascadingMember 0 0 0 0.0%
Driver.DriverDepCascadingNominal 0 0 0 0.0%
Driver.DriverDepCascadingTopLevel 0 0 0 0.0%
Driver.DriverDepDynamic 0 0 0 0.0%
Driver.DriverDepExternal 0 0 0 0.0%
Driver.DriverDepMember 0 0 0 0.0%
Driver.DriverDepNominal 0 0 0 0.0%
Driver.DriverDepTopLevel 0 0 0 0.0%
Driver.NumDriverJobsRun 27,113 27,113 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 966,133,302,720 965,873,405,872 -259,896,848 -0.03%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 193,570 193,570 0 0.0%
IRModule.NumIRBasicBlocks 6,633,689 6,633,689 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,283,835 3,283,835 0 0.0%
IRModule.NumIRGlobals 3,440,836 3,440,836 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 84,984,954 84,984,955 1 0.0%
IRModule.NumIRNamedMetaData 130,380 130,380 0 0.0%
IRModule.NumIRValueSymbols 6,084,052 6,084,052 0 0.0%
LLVM.NumLLVMBytesOutput 1,747,331,742 1,747,330,674 -1,068 -0.0%
Parse.NumFunctionsParsed 262,392 262,392 0 0.0%
Parse.NumIterableDeclContextParsed 695,396 695,386 -10 -0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,677,318 1,677,317 -1 -0.0%
SILModule.NumSILGenGlobalVariables 53,724 53,724 0 0.0%
SILModule.NumSILGenVtables 17,510 17,510 0 0.0%
SILModule.NumSILGenWitnessTables 70,986 70,986 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,398,231 2,398,231 0 0.0%
SILModule.NumSILOptGlobalVariables 55,333 55,333 0 0.0%
SILModule.NumSILOptVtables 29,880 29,880 0 0.0%
SILModule.NumSILOptWitnessTables 155,612 155,612 0 0.0%
Sema.AccessLevelRequest 12,654,388 12,576,144 -78,244 -0.62%
Sema.AttachedFunctionBuilderRequest 7 7 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 503,184 503,184 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,486,495 2,486,493 -2 -0.0%
Sema.CollectOverriddenDeclsRequest 7,967,116 7,911,825 -55,291 -0.69%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 17 17 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 84,921 84,919 -2 -0.0%
Sema.DefaultDefinitionTypeRequest 7,764 7,764 0 0.0%
Sema.DefaultTypeRequest 452,118 454,646 2,528 0.56%
Sema.EmittedMembersRequest 25,284 25,284 0 0.0%
Sema.EnumRawTypeRequest 22,534 22,534 0 0.0%
Sema.ExistentialConformsToSelfRequest 20,582 20,556 -26 -0.13%
Sema.ExistentialTypeSupportedRequest 16,176 16,176 0 0.0%
Sema.ExtendedNominalRequest 4,720,345 4,714,432 -5,913 -0.13%
Sema.FunctionBuilderTypeRequest 7 7 0 0.0%
Sema.GetDestructorRequest 25,738 25,738 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 0 0 0 0.0%
Sema.InheritedDeclsReferencedRequest 5,633,951 5,626,979 -6,972 -0.12%
Sema.InheritedTypeRequest 297,013 296,958 -55 -0.02%
Sema.InitKindRequest 103,569 103,567 -2 -0.0%
Sema.IsAccessorTransparentRequest 307,901 307,901 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,595,535 1,595,535 0 0.0%
Sema.IsFinalRequest 4,500,214 4,493,548 -6,666 -0.15%
Sema.IsGetterMutatingRequest 426,060 426,060 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,400,601 2,400,407 -194 -0.01%
Sema.IsObjCRequest 1,538,801 1,538,219 -582 -0.04%
Sema.IsSetterMutatingRequest 340,469 340,469 0 0.0%
Sema.LazyStoragePropertyRequest 2,400 2,400 0 0.0%
Sema.MangleLocalTypeDeclRequest 482 482 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 19,269 19,261 -8 -0.04%
Sema.NamedLazyMemberLoadSuccessCount 28,061,150 28,149,551 88,401 0.32%
Sema.NominalTypeLookupDirectCount 35,619,501 35,625,156 5,655 0.02%
Sema.NumAccessorBodiesSynthesized 183,634 183,634 0 0.0%
Sema.NumAccessorsSynthesized 282,537 282,537 0 0.0%
Sema.NumConformancesDeserialized 9,080,135 9,053,758 -26,377 -0.29%
Sema.NumCyclicOneWayComponentsCollapsed 0 0 0 0.0%
Sema.NumDeclsDeserialized 70,900,424 70,694,717 -205,707 -0.29%
Sema.NumDeclsTypechecked 1,370,625 1,370,625 0 0.0%
Sema.NumDeclsValidated 2,446,940 2,446,925 -15 -0.0%
Sema.NumFunctionsTypechecked 513,611 513,611 0 0.0%
Sema.NumGenericSignatureBuilders 1,346,196 1,343,804 -2,392 -0.18%
Sema.NumLazyGenericEnvironments 12,867,306 12,827,255 -40,051 -0.31%
Sema.NumLazyGenericEnvironmentsLoaded 299,606 299,563 -43 -0.01%
Sema.NumLazyIterableDeclContexts 8,397,774 8,388,504 -9,270 -0.11%
Sema.NumLazyRequirementSignatures 845,302 844,796 -506 -0.06%
Sema.NumLazyRequirementSignaturesLoaded 562,534 562,164 -370 -0.07%
Sema.NumTypesDeserialized 20,454,082 20,413,644 -40,438 -0.2%
Sema.NumTypesValidated 1,776,269 1,776,260 -9 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 5,060,646 5,064,217 3,571 0.07%
Sema.OpaqueReadOwnershipRequest 268,183 268,183 0 0.0%
Sema.OverriddenDeclsRequest 2,412,452 2,405,580 -6,872 -0.28%
Sema.PropertyWrapperBackingPropertyInfoRequest 498,138 498,138 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 503,184 503,184 0 0.0%
Sema.PropertyWrapperMutabilityRequest 599,852 599,852 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 5 5 0 0.0%
Sema.ProtocolRequiresClassRequest 78,427 78,366 -61 -0.08%
Sema.ProvideDefaultImplForRequest 7,967,116 7,911,825 -55,291 -0.69%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 105,257 105,255 -2 -0.0%
Sema.RequirementSignatureRequest 647,483 647,058 -425 -0.07%
Sema.RequiresOpaqueAccessorsRequest 1,287,023 1,287,023 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 259,425 259,425 0 0.0%
Sema.ResilienceExpansionRequest 1,713,172 1,713,163 -9 -0.0%
Sema.ResolveProtocolNameRequest 0 0 0 0.0%
Sema.RootAndResultTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.RootTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.SelfAccessKindRequest 5,395,522 5,393,127 -2,395 -0.04%
Sema.SelfBoundsFromWhereClauseRequest 7,458,928 7,449,422 -9,506 -0.13%
Sema.SetterAccessLevelRequest 147,407 147,407 0 0.0%
Sema.StorageImplInfoRequest 1,161,221 1,161,219 -2 -0.0%
Sema.StoredPropertiesAndMissingMembersRequest 29,571 29,571 0 0.0%
Sema.StoredPropertiesRequest 309,075 309,075 0 0.0%
Sema.StructuralTypeRequest 0 0 0 0.0%
Sema.SuperclassDeclRequest 435,206 434,844 -362 -0.08%
Sema.SuperclassTypeRequest 49,973 49,972 -1 -0.0%
Sema.SynthesizeAccessorRequest 282,537 282,537 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 513,611 513,611 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 46,710 46,708 -2 -0.0%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.USRGenerationRequest 9,118,913 9,062,842 -56,071 -0.61%
Sema.UnderlyingTypeDeclsReferencedRequest 244,329 244,016 -313 -0.13%

Release

release brief

Regressed (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 46,494,921,868,982 47,225,183,903,823 730,262,034,841 1.57% ⛔
time.swift-driver.wall 7379.6s 7497.0s 117.4s 1.59% ⛔
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 1,510,944,758 1,510,942,826 -1,932 -0.0%

release detailed

Regressed (1)
name old new delta delta_pct
Sema.NumConstraintScopes 24,155,787 29,171,434 5,015,647 20.76% ⛔
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (20)
name old new delta delta_pct
AST.NumLoadedModules 29,573 29,573 0 0.0%
AST.NumTotalClangImportedEntities 1,209,178 1,209,178 0 0.0%
IRModule.NumIRBasicBlocks 5,572,175 5,572,167 -8 -0.0%
IRModule.NumIRFunctions 2,799,173 2,799,173 0 0.0%
IRModule.NumIRGlobals 2,960,580 2,960,580 0 0.0%
IRModule.NumIRInsts 52,362,795 52,362,774 -21 -0.0%
IRModule.NumIRValueSymbols 5,412,198 5,412,198 0 0.0%
LLVM.NumLLVMBytesOutput 1,510,944,758 1,510,942,826 -1,932 -0.0%
SILModule.NumSILGenFunctions 1,171,408 1,171,407 -1 -0.0%
SILModule.NumSILOptFunctions 1,658,469 1,658,469 0 0.0%
Sema.NumConformancesDeserialized 3,886,831 3,889,454 2,623 0.07%
Sema.NumDeclsDeserialized 10,270,152 10,271,602 1,450 0.01%
Sema.NumDeclsValidated 1,790,705 1,790,705 0 0.0%
Sema.NumFunctionsTypechecked 517,375 517,375 0 0.0%
Sema.NumGenericSignatureBuilders 296,025 296,031 6 0.0%
Sema.NumLazyGenericEnvironments 2,023,055 2,023,082 27 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 35,202 35,208 6 0.02%
Sema.NumLazyIterableDeclContexts 1,303,466 1,304,483 1,017 0.08%
Sema.NumTypesDeserialized 5,502,505 5,502,769 264 0.0%
Sema.NumTypesValidated 967,408 967,408 0 0.0%

@DougGregor
Copy link
Member Author

This conflicts heavily with #26779, which goes back to the way Swift 5.1 found "all mentions" when gathering constraints. Looking at the total number of constraint scopes seen as part of processing the source compatibility suite:

I suspect that we can come up with tighter heuristics that gather everything that the solver needs to proceed after binding a type variable, but without grabbing too many "extra" constraints that shouldn't be reprocessed. Until then---or we make up the difference somewhere else---this pull request will remain open but unmerged.

@DougGregor
Copy link
Member Author

Also, landing this means we can revert #26749

@DougGregor
Copy link
Member Author

Obsoleted by #30886 !

@DougGregor DougGregor closed this Apr 10, 2020
@DougGregor DougGregor deleted the constraint-graph-all-mentions branch April 10, 2020 16:45
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