Skip to content

[Constraint graph] Having "gathering all mentions" mean "gathering more mentions" #26718

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 more mentions, rather
than some subset of them. This is meant to strike a balance that
fixes rdar://problem/54322807 while not greatly expanding the set
of constraints that are repeatedly visited.

…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.
…raints

Most clients of gatherConstraints() only care about the constraints
directly on the given type variable or other type variables equivalent
to it, while some also want to see constraints on fixed bindings as
well. Split "gathering kind" further so we do less work to retrieve
the constraints within an equivalence class for clients that only need
that information.
Most of the logic is identical to that of AllMentions, except that we
don't look through fixed bindings or traverse constraints.
…onstraints.

Mimic the Swift <= 5.1 behavior of visiting only a single level of
fixed bindings when gathering constraints, which should limit the
amount of reprocessing of constraints.
@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

@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 46,171,788,126,089 47,048,289,117,853 876,500,991,764 1.9% ⛔
time.swift-driver.wall 5133.1s 5228.1s 95.0s 1.85% ⛔
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,787,396,820 1,787,413,162 16,342 0.0%

debug-batch detailed

Regressed (9)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 46,171,788,126,089 47,048,289,117,853 876,500,991,764 1.9% ⛔
Sema.AccessLevelRequest 11,827,343 12,047,418 220,075 1.86% ⛔
Sema.CollectOverriddenDeclsRequest 7,190,531 7,368,842 178,311 2.48% ⛔
Sema.NumConstraintScopes 24,766,015 29,504,570 4,738,555 19.13% ⛔
Sema.NumConstraintsConsideredForEdgeContraction 74,019,845 117,687,898 43,668,053 59.0% ⛔
Sema.NumLeafScopes 16,026,259 18,797,277 2,771,018 17.29% ⛔
Sema.OverriddenDeclsRequest 2,381,779 2,407,066 25,287 1.06% ⛔
Sema.ProvideDefaultImplForRequest 7,190,531 7,368,842 178,311 2.48% ⛔
Sema.USRGenerationRequest 8,410,795 8,584,380 173,585 2.06% ⛔
Improved (2)
name old new delta delta_pct
Driver.NumDriverPipePolls 66,793 65,550 -1,243 -1.86% ✅
Driver.NumDriverPipeReads 54,508 53,346 -1,162 -2.13% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (134)
name old new delta delta_pct
AST.NumASTBytesAllocated 63,582,946,851 64,093,301,551 510,354,700 0.8%
AST.NumDecls 140,030 140,030 0 0.0%
AST.NumDependencies 321,479 321,480 1 0.0%
AST.NumInfixOperators 53,785 53,785 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 399,673 399,673 0 0.0%
AST.NumLocalTypeDecls 253 253 0 0.0%
AST.NumObjCMethods 24,715 24,715 0 0.0%
AST.NumPostfixOperators 23 23 0 0.0%
AST.NumPrecedenceGroups 25,673 25,673 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 189 189 0 0.0%
AST.NumReferencedMemberNames 6,323,741 6,323,750 9 0.0%
AST.NumReferencedTopLevelNames 477,061 477,061 0 0.0%
AST.NumSourceBuffers 566,026 566,026 0 0.0%
AST.NumSourceLines 4,685,853 4,685,853 0 0.0%
AST.NumSourceLinesPerSecond 3,381,504 3,380,356 -1,148 -0.03%
AST.NumTotalClangImportedEntities 6,429,938 6,448,522 18,584 0.29%
Driver.ChildrenMaxRSS 237,332,856,832 239,071,602,688 1,738,745,856 0.73%
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,909 27,909 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 1,321,719,227,376 1,327,923,299,280 6,204,071,904 0.47%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 197,270 197,270 0 0.0%
IRModule.NumIRBasicBlocks 6,801,933 6,801,933 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,364,989 3,364,989 0 0.0%
IRModule.NumIRGlobals 3,523,538 3,523,538 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 86,665,304 86,665,305 1 0.0%
IRModule.NumIRNamedMetaData 134,240 134,240 0 0.0%
IRModule.NumIRValueSymbols 6,233,388 6,233,388 0 0.0%
LLVM.NumLLVMBytesOutput 1,787,396,820 1,787,413,162 16,342 0.0%
Parse.NumFunctionsParsed 268,004 268,004 0 0.0%
Parse.NumIterableDeclContextParsed 908,694 908,741 47 0.01%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,709,913 1,709,912 -1 -0.0%
SILModule.NumSILGenGlobalVariables 53,884 53,884 0 0.0%
SILModule.NumSILGenVtables 18,582 18,582 0 0.0%
SILModule.NumSILGenWitnessTables 72,202 72,202 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,442,258 2,442,258 0 0.0%
SILModule.NumSILOptGlobalVariables 55,509 55,509 0 0.0%
SILModule.NumSILOptVtables 31,344 31,344 0 0.0%
SILModule.NumSILOptWitnessTables 157,819 157,819 0 0.0%
Sema.AttachedFunctionBuilderRequest 7 7 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 516,068 516,068 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,583,293 2,583,291 -2 -0.0%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 17 17 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 95,649 95,656 7 0.01%
Sema.DefaultDefinitionTypeRequest 8,105 8,105 0 0.0%
Sema.DefaultTypeRequest 460,598 463,134 2,536 0.55%
Sema.EmittedMembersRequest 27,961 27,961 0 0.0%
Sema.EnumRawTypeRequest 25,101 25,101 0 0.0%
Sema.ExistentialConformsToSelfRequest 23,279 23,412 133 0.57%
Sema.ExistentialTypeSupportedRequest 17,732 17,732 0 0.0%
Sema.ExtendedNominalRequest 5,454,318 5,465,770 11,452 0.21%
Sema.FunctionBuilderTypeRequest 7 7 0 0.0%
Sema.GetDestructorRequest 28,370 28,370 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 0 0 0 0.0%
Sema.InheritedDeclsReferencedRequest 6,187,653 6,215,068 27,415 0.44%
Sema.InheritedTypeRequest 332,105 332,589 484 0.15%
Sema.InitKindRequest 112,533 112,531 -2 -0.0%
Sema.IsAccessorTransparentRequest 320,351 320,351 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,665,856 1,665,856 0 0.0%
Sema.IsFinalRequest 4,561,909 4,584,552 22,643 0.5%
Sema.IsGetterMutatingRequest 443,331 443,331 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,529,898 2,532,719 2,821 0.11%
Sema.IsObjCRequest 1,602,399 1,605,051 2,652 0.17%
Sema.IsSetterMutatingRequest 350,179 350,179 0 0.0%
Sema.LazyStoragePropertyRequest 2,603 2,603 0 0.0%
Sema.MangleLocalTypeDeclRequest 506 506 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 22,300 22,318 18 0.08%
Sema.NamedLazyMemberLoadSuccessCount 29,714,506 29,787,979 73,473 0.25%
Sema.NominalTypeLookupDirectCount 36,610,391 36,745,772 135,381 0.37%
Sema.NumAccessorBodiesSynthesized 189,386 189,386 0 0.0%
Sema.NumAccessorsSynthesized 296,352 296,352 0 0.0%
Sema.NumConformancesDeserialized 9,337,241 9,414,101 76,860 0.82%
Sema.NumCyclicOneWayComponentsCollapsed 0 0 0 0.0%
Sema.NumDeclsDeserialized 75,090,429 75,637,297 546,868 0.73%
Sema.NumDeclsTypechecked 1,403,800 1,403,800 0 0.0%
Sema.NumDeclsValidated 2,589,612 2,589,599 -13 -0.0%
Sema.NumFunctionsTypechecked 527,391 527,391 0 0.0%
Sema.NumGenericSignatureBuilders 1,488,826 1,493,021 4,195 0.28%
Sema.NumLazyGenericEnvironments 13,703,960 13,775,636 71,676 0.52%
Sema.NumLazyGenericEnvironmentsLoaded 323,240 323,702 462 0.14%
Sema.NumLazyIterableDeclContexts 9,731,530 9,745,468 13,938 0.14%
Sema.NumLazyRequirementSignatures 1,032,438 1,032,530 92 0.01%
Sema.NumLazyRequirementSignaturesLoaded 663,172 663,231 59 0.01%
Sema.NumTypesDeserialized 22,294,081 22,390,314 96,233 0.43%
Sema.NumTypesValidated 1,933,097 1,933,094 -3 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 6,335,096 6,316,708 -18,388 -0.29%
Sema.OpaqueReadOwnershipRequest 282,442 282,442 0 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 510,676 510,676 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 516,068 516,068 0 0.0%
Sema.PropertyWrapperMutabilityRequest 622,097 622,097 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 5 5 0 0.0%
Sema.ProtocolRequiresClassRequest 91,954 92,469 515 0.56%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 112,214 112,214 0 0.0%
Sema.RequirementSignatureRequest 764,325 764,879 554 0.07%
Sema.RequiresOpaqueAccessorsRequest 1,325,609 1,325,609 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 273,705 273,705 0 0.0%
Sema.ResilienceExpansionRequest 1,843,512 1,843,506 -6 -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 6,361,679 6,366,188 4,509 0.07%
Sema.SelfBoundsFromWhereClauseRequest 8,027,260 8,070,178 42,918 0.53%
Sema.SetterAccessLevelRequest 151,143 151,143 0 0.0%
Sema.StorageImplInfoRequest 1,209,666 1,209,664 -2 -0.0%
Sema.StoredPropertiesAndMissingMembersRequest 32,454 32,454 0 0.0%
Sema.StoredPropertiesRequest 350,475 350,475 0 0.0%
Sema.StructuralTypeRequest 0 0 0 0.0%
Sema.SuperclassDeclRequest 500,062 500,945 883 0.18%
Sema.SuperclassTypeRequest 56,576 56,575 -1 -0.0%
Sema.SynthesizeAccessorRequest 296,352 296,352 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 527,391 527,391 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 52,043 52,050 7 0.01%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.UnderlyingTypeDeclsReferencedRequest 269,720 270,711 991 0.37%

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 47,108,002,327,376 46,668,598,665,061 -439,403,662,315 -0.93%
LLVM.NumLLVMBytesOutput 1,541,954,390 1,526,910,520 -15,043,870 -0.98%
time.swift-driver.wall 8569.3s 8497.3s -72.0s -0.84%

release detailed

Regressed (1)
name old new delta delta_pct
Sema.NumConstraintScopes 24,317,693 28,798,087 4,480,394 18.42% ⛔
Improved (19)
name old new delta delta_pct
AST.NumLoadedModules 30,369 29,493 -876 -2.88% ✅
AST.NumTotalClangImportedEntities 1,233,782 1,218,008 -15,774 -1.28% ✅
IRModule.NumIRBasicBlocks 5,633,570 5,525,386 -108,184 -1.92% ✅
IRModule.NumIRFunctions 2,857,348 2,805,691 -51,657 -1.81% ✅
IRModule.NumIRGlobals 3,027,793 2,981,217 -46,576 -1.54% ✅
IRModule.NumIRInsts 53,118,724 52,305,966 -812,758 -1.53% ✅
IRModule.NumIRValueSymbols 5,527,774 5,433,801 -93,973 -1.7% ✅
SILModule.NumSILGenFunctions 1,191,822 1,164,719 -27,103 -2.27% ✅
SILModule.NumSILOptFunctions 1,682,305 1,642,078 -40,227 -2.39% ✅
Sema.NumConformancesDeserialized 3,932,625 3,827,552 -105,073 -2.67% ✅
Sema.NumDeclsDeserialized 10,465,618 10,175,230 -290,388 -2.77% ✅
Sema.NumDeclsValidated 1,826,401 1,791,127 -35,274 -1.93% ✅
Sema.NumFunctionsTypechecked 531,011 520,334 -10,677 -2.01% ✅
Sema.NumGenericSignatureBuilders 302,943 295,602 -7,341 -2.42% ✅
Sema.NumLazyGenericEnvironments 2,065,173 2,007,483 -57,690 -2.79% ✅
Sema.NumLazyGenericEnvironmentsLoaded 35,778 34,868 -910 -2.54% ✅
Sema.NumLazyIterableDeclContexts 1,332,128 1,299,343 -32,785 -2.46% ✅
Sema.NumTypesDeserialized 5,601,647 5,450,179 -151,468 -2.7% ✅
Sema.NumTypesValidated 989,452 968,664 -20,788 -2.1% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 1,541,954,390 1,526,910,520 -15,043,870 -0.98%

@DougGregor
Copy link
Member Author

This approach is a dead-end; better to focus on getting the right answer with appropriate performance via #26691

@DougGregor DougGregor closed this Aug 23, 2019
@DougGregor DougGregor deleted the constraint-graph-most-mentions branch August 23, 2019 16:21
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