Skip to content

Fix some low-hanging request evaluator performance fruit #29088

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 2 commits into from
Jan 9, 2020

Conversation

slavapestov
Copy link
Contributor

We've added a lot of new requests lately and converted more of the declaration checker to use requests. This has led to an increase in per-request overhead. This PR addresses some of this overhead:

  • Don't build the request dependency graph by default since it's currently only used for debugging
  • Look for a cached result before checking for a cycle to avoid expensive AnyRequest allocation

…ld-request-dependency-graph

This adds a measurable amount of runtime overhead, but it's only
needed for debugging.
This improves performance in the common case where the result has
already been cached, because the cycle check constructs an
AnyRequest existential, which is expensive.
@slavapestov slavapestov force-pushed the request-eval-perf-hack branch from ba03f78 to 1ed5453 Compare January 9, 2020 03:39
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@DougGregor if this PR looks OK, please also approve the 5.2 cherry-pick -- it should be very low risk: #29089

Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

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

LGTM

@CodaFi
Copy link
Contributor

CodaFi commented Jan 9, 2020

Just to see wall time and heap traffic stuff - don't let this block anything.

@swift-ci please test compiler performance

@slavapestov slavapestov merged commit 724ccf0 into swiftlang:master Jan 9, 2020
@swift-ci
Copy link
Contributor

swift-ci commented Jan 9, 2020

Summary for master full

Unexpected test results, excluded stats for RxCocoa, SwifterSwift, Base64CoderSwiftUI

Regressions found (see below)

Debug-batch

debug-batch brief

Regressed (0)
name old new delta delta_pct
Improved (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 42,772,723,438,558 39,794,656,807,732 -2,978,066,630,826 -6.96% ✅
time.swift-driver.wall 3208.0s 3008.2s -199.8s -6.23% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 1,802,632,926 1,802,633,240 314 0.0%

debug-batch detailed

Regressed (1)
name old new delta delta_pct
AST.NumSourceLinesPerSecond 4,506,376 4,854,478 348,102 7.72% ⛔
Improved (10)
name old new delta delta_pct
Driver.ChildrenMaxRSS 232,091,904,000 216,211,144,704 -15,880,759,296 -6.84% ✅
Driver.NumDriverPipePolls 110,397 107,226 -3,171 -2.87% ✅
Driver.NumDriverPipeReads 101,434 98,334 -3,100 -3.06% ✅
Frontend.MaxMallocUsage 916,697,828,928 811,954,535,296 -104,743,293,632 -11.43% ✅
Frontend.NumInstructionsExecuted 42,772,723,438,558 39,794,656,807,732 -2,978,066,630,826 -6.96% ✅
Sema.AccessLevelRequest 10,851,650 10,644,086 -207,564 -1.91% ✅
Sema.CollectOverriddenDeclsRequest 6,440,414 6,276,054 -164,360 -2.55% ✅
Sema.GenericParamListRequest 10,608,289 10,470,107 -138,182 -1.3% ✅
Sema.ProvideDefaultImplForRequest 6,440,414 6,276,054 -164,360 -2.55% ✅
Sema.USRGenerationRequest 7,729,369 7,563,311 -166,058 -2.15% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (197)
name old new delta delta_pct
AST.ImportSetCacheHit 1,595,525 1,595,276 -249 -0.02%
AST.ImportSetCacheMiss 694,519 694,383 -136 -0.02%
AST.ImportSetFoldHit 373,170 373,164 -6 -0.0%
AST.ImportSetFoldMiss 321,349 321,219 -130 -0.04%
AST.ModuleShadowCacheHit 1,249,628 1,248,677 -951 -0.08%
AST.ModuleShadowCacheMiss 10,086 10,061 -25 -0.25%
AST.ModuleVisibilityCacheHit 28,905 28,905 0 0.0%
AST.ModuleVisibilityCacheMiss 6,638 6,638 0 0.0%
AST.NumASTBytesAllocated 51,547,509,264 51,054,716,558 -492,792,706 -0.96%
AST.NumASTScopeLookups 3,528,827 3,528,528 -299 -0.01%
AST.NumBraceStmtASTScopeExpansions 619,325 619,325 0 0.0%
AST.NumBraceStmtASTScopes 619,325 619,325 0 0.0%
AST.NumDecls 139,853 139,853 0 0.0%
AST.NumDependencies 301,265 301,274 9 0.0%
AST.NumInfixOperators 53,695 53,695 0 0.0%
AST.NumIterableTypeBodyASTScopeExpansions 227,928 227,923 -5 -0.0%
AST.NumIterableTypeBodyASTScopes 279,371 279,313 -58 -0.02%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 281,092 281,092 0 0.0%
AST.NumLocalTypeDecls 250 250 0 0.0%
AST.NumModuleLookupClassMember 6,927 6,927 0 0.0%
AST.NumModuleLookupValue 41,339,684 41,325,539 -14,145 -0.03%
AST.NumObjCMethods 24,240 24,240 0 0.0%
AST.NumPostfixOperators 49 49 0 0.0%
AST.NumPrecedenceGroups 25,840 25,840 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 189 189 0 0.0%
AST.NumReferencedMemberNames 6,309,639 6,309,639 0 0.0%
AST.NumReferencedTopLevelNames 476,239 476,239 0 0.0%
AST.NumSourceBuffers 338,426 338,426 0 0.0%
AST.NumSourceLines 4,717,684 4,717,684 0 0.0%
AST.NumTotalClangImportedEntities 4,874,398 4,855,820 -18,578 -0.38%
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 28,030 28,030 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 196,319 196,319 0 0.0%
IRModule.NumIRBasicBlocks 6,863,346 6,863,346 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,371,916 3,371,916 0 0.0%
IRModule.NumIRGlobals 3,682,372 3,682,372 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 87,970,516 87,970,516 0 0.0%
IRModule.NumIRNamedMetaData 135,380 135,380 0 0.0%
IRModule.NumIRValueSymbols 6,399,165 6,399,165 0 0.0%
LLVM.NumLLVMBytesOutput 1,802,632,926 1,802,633,240 314 0.0%
Parse.NumFunctionsParsed 268,976 268,976 0 0.0%
Parse.NumIterableDeclContextParsed 617,861 617,838 -23 -0.0%
Parse.ParseAbstractFunctionBodyRequest 246,113 246,113 0 0.0%
Parse.ParseMembersRequest 486,011 485,988 -23 -0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,701,394 1,701,394 0 0.0%
SILModule.NumSILGenGlobalVariables 53,554 53,554 0 0.0%
SILModule.NumSILGenVtables 18,627 18,627 0 0.0%
SILModule.NumSILGenWitnessTables 72,395 72,395 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,523,223 2,523,223 0 0.0%
SILModule.NumSILOptGlobalVariables 55,187 55,187 0 0.0%
SILModule.NumSILOptVtables 31,428 31,428 0 0.0%
SILModule.NumSILOptWitnessTables 169,304 169,304 0 0.0%
Sema.AbstractGenericSignatureRequest 30,630 30,630 0 0.0%
Sema.AnyObjectLookupRequest 281 281 0 0.0%
Sema.AreAllStoredPropertiesDefaultInitableRequest 21,023 21,023 0 0.0%
Sema.AttachedFunctionBuilderRequest 3 3 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 538,586 538,586 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,286,190 2,286,183 -7 -0.0%
Sema.CallerSideDefaultArgExprRequest 78,637 78,637 0 0.0%
Sema.ClassAncestryFlagsRequest 96,510 96,510 0 0.0%
Sema.CompareDeclSpecializationRequest 460,599 459,496 -1,103 -0.24%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 3 3 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 53,525 53,520 -5 -0.01%
Sema.DefaultArgumentExprRequest 38,177 38,177 0 0.0%
Sema.DefaultArgumentInitContextRequest 454 454 0 0.0%
Sema.DefaultDefinitionTypeRequest 7,790 7,790 0 0.0%
Sema.DefaultTypeRequest 454,210 454,210 0 0.0%
Sema.DynamicallyReplacedDeclRequest 1,013,245 1,013,245 0 0.0%
Sema.EmittedMembersRequest 25,899 25,899 0 0.0%
Sema.EnumRawTypeRequest 21,816 21,816 0 0.0%
Sema.EnumRawValuesRequest 10,526 10,526 0 0.0%
Sema.ExistentialConformsToSelfRequest 12,494 12,513 19 0.15%
Sema.ExistentialTypeSupportedRequest 15,806 15,806 0 0.0%
Sema.ExpandASTScopeRequest 6,428,621 6,428,523 -98 -0.0%
Sema.ExtendedNominalRequest 516,280 516,280 0 0.0%
Sema.ExtendedTypeRequest 75,641 75,639 -2 -0.0%
Sema.FunctionBuilderTypeRequest 3 3 0 0.0%
Sema.FunctionOperatorRequest 51,330 51,330 0 0.0%
Sema.GenericSignatureRequest 4,501,684 4,487,715 -13,969 -0.31%
Sema.GetDestructorRequest 26,389 26,389 0 0.0%
Sema.HasCircularInheritanceRequest 22,567 22,567 0 0.0%
Sema.HasCircularInheritedProtocolsRequest 10,021 10,021 0 0.0%
Sema.HasCircularRawValueRequest 8,958 8,958 0 0.0%
Sema.HasDefaultInitRequest 51,660 51,660 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 617,715 617,228 -487 -0.08%
Sema.HasMemberwiseInitRequest 19,272 19,272 0 0.0%
Sema.HasMissingDesignatedInitializersRequest 24,843 24,843 0 0.0%
Sema.HasUserDefinedDesignatedInitRequest 51,670 51,670 0 0.0%
Sema.InferredGenericSignatureRequest 163,450 163,447 -3 -0.0%
Sema.InheritedDeclsReferencedRequest 5,685,604 5,650,361 -35,243 -0.62%
Sema.InheritedTypeRequest 277,316 277,433 117 0.04%
Sema.InheritsSuperclassInitializersRequest 26,251 26,251 0 0.0%
Sema.InitKindRequest 91,279 91,279 0 0.0%
Sema.InterfaceTypeRequest 14,440,237 14,303,736 -136,501 -0.95%
Sema.IsABICompatibleOverrideRequest 135,234 135,234 0 0.0%
Sema.IsAccessorTransparentRequest 309,083 309,083 0 0.0%
Sema.IsCallableNominalTypeRequest 2,089 2,089 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,686,470 1,686,470 0 0.0%
Sema.IsFinalRequest 2,432,392 2,415,127 -17,265 -0.71%
Sema.IsGetterMutatingRequest 415,698 415,698 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,367,527 2,367,536 9 0.0%
Sema.IsObjCRequest 1,503,745 1,501,957 -1,788 -0.12%
Sema.IsSetterMutatingRequest 336,825 336,825 0 0.0%
Sema.IsStaticRequest 3,011,741 3,005,225 -6,516 -0.22%
Sema.LazyStoragePropertyRequest 2,197 2,197 0 0.0%
Sema.LookupInModuleRequest 5,617,579 5,609,071 -8,508 -0.15%
Sema.LookupPrecedenceGroupRequest 175,916 175,916 0 0.0%
Sema.MangleLocalTypeDeclRequest 500 500 0 0.0%
Sema.ModuleQualifiedLookupRequest 2,540,365 2,532,146 -8,219 -0.32%
Sema.NamedLazyMemberLoadFailureCount 15,146 15,120 -26 -0.17%
Sema.NamedLazyMemberLoadSuccessCount 11,134,328 11,151,265 16,937 0.15%
Sema.NamingPatternRequest 177,254 177,247 -7 -0.0%
Sema.NeedsNewVTableEntryRequest 661,583 661,583 0 0.0%
Sema.NominalTypeLookupDirectCount 33,055,670 32,965,530 -90,140 -0.27%
Sema.NumAccessorBodiesSynthesized 189,102 189,102 0 0.0%
Sema.NumAccessorsSynthesized 277,639 277,639 0 0.0%
Sema.NumConformancesDeserialized 8,227,198 8,150,402 -76,796 -0.93%
Sema.NumConstraintScopes 27,602,003 27,593,326 -8,677 -0.03%
Sema.NumConstraintsConsideredForEdgeContraction 92,796,631 92,794,334 -2,297 -0.0%
Sema.NumCyclicOneWayComponentsCollapsed 0 0 0 0.0%
Sema.NumDeclsDeserialized 63,374,465 62,802,021 -572,444 -0.9%
Sema.NumDeclsTypechecked 1,412,179 1,412,179 0 0.0%
Sema.NumFunctionsTypechecked 529,260 529,260 0 0.0%
Sema.NumGenericSignatureBuilders 1,192,656 1,188,578 -4,078 -0.34%
Sema.NumLazyIterableDeclContexts 7,579,213 7,557,404 -21,809 -0.29%
Sema.NumLazyRequirementSignatures 761,580 761,034 -546 -0.07%
Sema.NumLazyRequirementSignaturesLoaded 568,167 567,776 -391 -0.07%
Sema.NumLeafScopes 17,575,286 17,567,705 -7,581 -0.04%
Sema.NumTypesDeserialized 19,472,519 19,379,156 -93,363 -0.48%
Sema.NumTypesValidated 1,373,605 1,373,593 -12 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 4,619,404 4,631,074 11,670 0.25%
Sema.OpaqueReadOwnershipRequest 262,684 262,684 0 0.0%
Sema.OpaqueResultTypeRequest 0 0 0 0.0%
Sema.OperatorPrecedenceGroupRequest 724 724 0 0.0%
Sema.OverriddenDeclsRequest 2,691,292 2,675,979 -15,313 -0.57%
Sema.ParamSpecifierRequest 1,190,788 1,190,783 -5 -0.0%
Sema.PatternBindingEntryRequest 433,187 433,180 -7 -0.0%
Sema.PatternTypeRequest 554,490 554,483 -7 -0.0%
Sema.PreCheckFunctionBuilderRequest 0 0 0 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 533,564 533,564 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 538,586 538,586 0 0.0%
Sema.PropertyWrapperMutabilityRequest 610,555 610,555 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 1 1 0 0.0%
Sema.ProtocolRequiresClassRequest 59,185 59,251 66 0.11%
Sema.QualifiedLookupRequest 6,681,639 6,666,929 -14,710 -0.22%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 107,348 107,343 -5 -0.0%
Sema.RequirementSignatureRequest 628,344 627,963 -381 -0.06%
Sema.RequiresOpaqueAccessorsRequest 1,286,458 1,286,458 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 253,458 253,458 0 0.0%
Sema.ResilienceExpansionRequest 1,697,147 1,697,135 -12 -0.0%
Sema.ResolveImplicitMemberRequest 354,560 353,690 -870 -0.25%
Sema.ResolveProtocolNameRequest 0 0 0 0.0%
Sema.ResultTypeRequest 633,311 633,313 2 0.0%
Sema.RootAndResultTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.RootTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.SelfAccessKindRequest 2,466,720 2,456,759 -9,961 -0.4%
Sema.SelfBoundsFromWhereClauseRequest 1,490,046 1,484,322 -5,724 -0.38%
Sema.SetterAccessLevelRequest 141,909 141,909 0 0.0%
Sema.StorageImplInfoRequest 1,375,310 1,375,310 0 0.0%
Sema.StoredPropertiesAndMissingMembersRequest 29,897 29,897 0 0.0%
Sema.StoredPropertiesRequest 305,301 305,301 0 0.0%
Sema.StructuralTypeRequest 2,078 2,078 0 0.0%
Sema.SuperclassDeclRequest 395,740 395,274 -466 -0.12%
Sema.SuperclassTypeRequest 52,539 52,539 0 0.0%
Sema.SynthesizeAccessorRequest 277,639 277,639 0 0.0%
Sema.SynthesizeDefaultInitRequest 4,810 4,810 0 0.0%
Sema.SynthesizeMemberwiseInitRequest 3,061 3,061 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 529,260 529,260 0 0.0%
Sema.TypeCheckSourceFileRequest 27,076 27,076 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 28,695 28,690 -5 -0.02%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.TypeWitnessRequest 8,337 8,338 1 0.01%
Sema.UnderlyingTypeDeclsReferencedRequest 308,750 307,761 -989 -0.32%
Sema.UnderlyingTypeRequest 33,849 33,849 0 0.0%
Sema.UnqualifiedLookupRequest 3,671,770 3,671,471 -299 -0.01%
Sema.ValueWitnessRequest 63,137 63,137 0 0.0%

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 51,014,111,235,979 49,360,661,207,187 -1,653,450,028,792 -3.24% ✅
time.swift-driver.wall 5764.5s 5509.5s -255.0s -4.42% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 1,926,362,828 1,926,364,192 1,364 0.0%

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) (18)
name old new delta delta_pct
AST.NumLoadedModules 30,053 30,053 0 0.0%
AST.NumTotalClangImportedEntities 1,182,860 1,182,860 0 0.0%
IRModule.NumIRBasicBlocks 5,447,970 5,447,970 0 0.0%
IRModule.NumIRFunctions 2,833,661 2,833,661 0 0.0%
IRModule.NumIRGlobals 3,193,845 3,193,845 0 0.0%
IRModule.NumIRInsts 53,509,050 53,509,050 0 0.0%
IRModule.NumIRValueSymbols 5,670,071 5,670,071 0 0.0%
LLVM.NumLLVMBytesOutput 1,926,362,828 1,926,364,192 1,364 0.0%
SILModule.NumSILGenFunctions 1,189,997 1,189,997 0 0.0%
SILModule.NumSILOptFunctions 1,733,021 1,733,021 0 0.0%
Sema.NumConformancesDeserialized 3,645,246 3,645,246 0 0.0%
Sema.NumConstraintScopes 27,313,772 27,313,772 0 0.0%
Sema.NumDeclsDeserialized 10,696,141 10,696,141 0 0.0%
Sema.NumFunctionsTypechecked 532,882 532,882 0 0.0%
Sema.NumGenericSignatureBuilders 281,460 281,460 0 0.0%
Sema.NumLazyIterableDeclContexts 1,318,546 1,318,546 0 0.0%
Sema.NumTypesDeserialized 5,413,853 5,413,853 0 0.0%
Sema.NumTypesValidated 826,777 826,777 0 0.0%

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