Skip to content

More lazy body synthesis #26105

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 13 commits into from
Jul 12, 2019
Merged

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Jul 12, 2019

Start improving lazy synthesis of function bodies:

  • Don't ask for a complete function body when we only need the source range
  • Don't have lazy body synthesizers mutate the function; return the synthesized body along with a flag indicating whether it is already type checked
  • Switch all Clang importer-synthesized bodies over to lazy synthesizers

A number of callers to AbstractFunctionDecl::getBody() were only
extracting the source range of the body... which can be retrieved more
efficiently with getBodySourceRange().
Instead of requiring that function body synthesizers will always call
setBody(), which is annoyingly stateful, have function body synthesizers
always return the synthesized brace statement along with a bit that
indicates whether the body was already type-checked. This takes us a
step closer to centralizing the mutation of the body of a function.
We don't have an effective lazy-synthesis mechanism for
Clang function bodies, and we were doing it eagerly already,
so at least be honest about it.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@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 ProcedureKit, Tagged, Wordy, SwifterSwift, Deferred

Regressions found (see below)

Debug-batch

debug-batch 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 23,435,999,271,171 23,472,267,989,830 36,268,718,659 0.15%
LLVM.NumLLVMBytesOutput 1,160,951,896 1,160,947,640 -4,256 -0.0%
time.swift-driver.wall 1628.7s 1633.6s 4.9s 0.3%

debug-batch detailed

Regressed (1)
name old new delta delta_pct
Sema.USRGenerationRequest 4,156,494 4,226,545 70,051 1.69% ⛔
Improved (3)
name old new delta delta_pct
Driver.NumDriverPipePolls 138,751 133,878 -4,873 -3.51% ✅
Driver.NumDriverPipeReads 136,757 132,017 -4,740 -3.47% ✅
Sema.NumGenericSignatureBuilders 869,605 766,611 -102,994 -11.84% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (114)
name old new delta delta_pct
AST.NumASTBytesAllocated 32,851,097,189 32,617,752,652 -233,344,537 -0.71%
AST.NumDecls 93,543 93,543 0 0.0%
AST.NumDependencies 136,800 136,792 -8 -0.01%
AST.NumInfixOperators 34,812 34,812 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 174,310 174,310 0 0.0%
AST.NumLocalTypeDecls 123 123 0 0.0%
AST.NumObjCMethods 15,290 15,290 0 0.0%
AST.NumPostfixOperators 18 18 0 0.0%
AST.NumPrecedenceGroups 17,193 17,193 0 0.0%
AST.NumPrefixOperators 60 60 0 0.0%
AST.NumReferencedDynamicNames 122 122 0 0.0%
AST.NumReferencedMemberNames 4,071,280 4,071,280 0 0.0%
AST.NumReferencedTopLevelNames 315,682 315,682 0 0.0%
AST.NumSourceBuffers 213,408 213,408 0 0.0%
AST.NumSourceLines 3,118,982 3,118,982 0 0.0%
AST.NumSourceLinesPerSecond 3,462,870 3,446,001 -16,869 -0.49%
AST.NumStoredPropertiesQueries 9,229,268 9,229,145 -123 -0.0%
AST.NumTotalClangImportedEntities 3,321,156 3,329,314 8,158 0.25%
Driver.ChildrenMaxRSS 131,256,825,856 131,389,960,192 133,134,336 0.1%
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 19,038 19,038 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 582,944,074,888 583,854,546,528 910,471,640 0.16%
Frontend.NumInstructionsExecuted 23,435,999,271,171 23,472,267,989,830 36,268,718,659 0.15%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 120,775 120,775 0 0.0%
IRModule.NumIRBasicBlocks 4,609,887 4,609,887 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 2,144,147 2,144,147 0 0.0%
IRModule.NumIRGlobals 2,243,379 2,243,379 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 60,935,359 60,935,359 0 0.0%
IRModule.NumIRNamedMetaData 92,490 92,490 0 0.0%
IRModule.NumIRValueSymbols 3,922,904 3,922,904 0 0.0%
LLVM.NumLLVMBytesOutput 1,160,951,896 1,160,947,640 -4,256 -0.0%
Parse.NumFunctionsParsed 171,430 171,430 0 0.0%
Parse.NumIterableDeclContextParsed 628,394 628,394 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,081,632 1,081,632 0 0.0%
SILModule.NumSILGenGlobalVariables 36,840 36,840 0 0.0%
SILModule.NumSILGenVtables 12,417 12,417 0 0.0%
SILModule.NumSILGenWitnessTables 46,027 46,027 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 1,535,399 1,535,399 0 0.0%
SILModule.NumSILOptGlobalVariables 37,716 37,716 0 0.0%
SILModule.NumSILOptVtables 20,593 20,593 0 0.0%
SILModule.NumSILOptWitnessTables 101,019 101,019 0 0.0%
Sema.AccessLevelRequest 6,632,365 6,698,865 66,500 1.0%
Sema.AttachedFunctionBuilderRequest 0 0 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 304,320 304,320 0 0.0%
Sema.AttachedPropertyWrappersRequest 1,265,528 1,265,528 0 0.0%
Sema.CustomAttrNominalRequest 0 0 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 49,418 49,419 1 0.0%
Sema.DefaultDefinitionTypeRequest 5,108 5,108 0 0.0%
Sema.DefaultTypeRequest 320,709 320,709 0 0.0%
Sema.EnumRawTypeRequest 13,877 13,877 0 0.0%
Sema.ExtendedNominalRequest 2,547,780 2,555,290 7,510 0.29%
Sema.FunctionBuilderTypeRequest 0 0 0 0.0%
Sema.InheritedDeclsReferencedRequest 3,083,769 3,105,235 21,466 0.7%
Sema.InheritedTypeRequest 200,615 200,646 31 0.02%
Sema.IsDynamicRequest 1,696,770 1,696,770 0 0.0%
Sema.IsFinalRequest 2,893,681 2,900,074 6,393 0.22%
Sema.IsGetterMutatingRequest 351,330 351,330 0 0.0%
Sema.IsObjCRequest 1,516,743 1,517,090 347 0.02%
Sema.IsSetterMutatingRequest 256,806 256,806 0 0.0%
Sema.LazyStoragePropertyRequest 1,912 1,912 0 0.0%
Sema.MangleLocalTypeDeclRequest 246 246 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 17,465 17,530 65 0.37%
Sema.NamedLazyMemberLoadSuccessCount 17,909,571 17,914,981 5,410 0.03%
Sema.NominalTypeLookupDirectCount 23,168,492 23,206,901 38,409 0.17%
Sema.NumConformancesDeserialized 5,147,040 5,175,968 28,928 0.56%
Sema.NumConstraintScopes 17,835,980 17,839,483 3,503 0.02%
Sema.NumConstraintsConsideredForEdgeContraction 52,790,380 52,791,691 1,311 0.0%
Sema.NumDeclsDeserialized 36,895,530 37,123,161 227,631 0.62%
Sema.NumDeclsFinalized 1,474,451 1,474,451 0 0.0%
Sema.NumDeclsTypechecked 888,291 888,291 0 0.0%
Sema.NumDeclsValidated 2,013,373 2,013,380 7 0.0%
Sema.NumFunctionsTypechecked 198,539 198,539 0 0.0%
Sema.NumLazyGenericEnvironments 6,883,167 6,904,231 21,064 0.31%
Sema.NumLazyGenericEnvironmentsLoaded 200,298 200,321 23 0.01%
Sema.NumLazyIterableDeclContexts 4,625,803 4,637,372 11,569 0.25%
Sema.NumLazyRequirementSignatures 467,916 468,138 222 0.05%
Sema.NumLazyRequirementSignaturesLoaded 314,376 314,564 188 0.06%
Sema.NumLeafScopes 11,463,430 11,466,345 2,915 0.03%
Sema.NumTypesDeserialized 11,278,781 11,314,213 35,432 0.31%
Sema.NumTypesValidated 1,484,987 1,484,998 11 0.0%
Sema.NumUnloadedLazyIterableDeclContexts 2,891,912 2,892,046 134 0.0%
Sema.OpaqueReadOwnershipRequest 367,991 367,991 0 0.0%
Sema.OverriddenDeclsRequest 1,924,568 1,929,857 5,289 0.27%
Sema.PropertyWrapperBackingPropertyInfoRequest 302,029 302,029 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 304,320 304,320 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 62,958 62,960 2 0.0%
Sema.RequirementSignatureRequest 365,581 365,803 222 0.06%
Sema.SelfAccessKindRequest 3,308,122 3,316,769 8,647 0.26%
Sema.SelfBoundsFromWhereClauseRequest 4,070,519 4,099,785 29,266 0.72%
Sema.SetterAccessLevelRequest 134,331 134,331 0 0.0%
Sema.StructuralTypeRequest 0 0 0 0.0%
Sema.SuperclassDeclRequest 254,835 255,014 179 0.07%
Sema.SuperclassTypeRequest 34,527 34,527 0 0.0%
Sema.TypeCheckFunctionBodyRequest 318,606 318,606 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 27,701 27,702 1 0.0%
Sema.UnderlyingTypeDeclsReferencedRequest 140,671 140,935 264 0.19%

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 30,525,008,987,090 30,519,509,109,424 -5,499,877,666 -0.02%
LLVM.NumLLVMBytesOutput 993,095,506 993,096,666 1,160 0.0%
time.swift-driver.wall 3211.4s 3216.0s 4.6s 0.14%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (1)
name old new delta delta_pct
Sema.NumGenericSignatureBuilders 207,868 183,005 -24,863 -11.96% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (20)
name old new delta delta_pct
AST.NumLoadedModules 17,619 17,619 0 0.0%
AST.NumTotalClangImportedEntities 778,391 778,391 0 0.0%
IRModule.NumIRBasicBlocks 3,931,136 3,931,136 0 0.0%
IRModule.NumIRFunctions 1,811,885 1,811,885 0 0.0%
IRModule.NumIRGlobals 1,989,946 1,989,946 0 0.0%
IRModule.NumIRInsts 36,194,966 36,194,966 0 0.0%
IRModule.NumIRValueSymbols 3,533,288 3,533,288 0 0.0%
LLVM.NumLLVMBytesOutput 993,095,506 993,096,666 1,160 0.0%
SILModule.NumSILGenFunctions 748,037 748,037 0 0.0%
SILModule.NumSILOptFunctions 1,001,547 1,001,547 0 0.0%
Sema.NumConformancesDeserialized 2,288,921 2,288,921 0 0.0%
Sema.NumConstraintScopes 17,599,082 17,599,082 0 0.0%
Sema.NumDeclsDeserialized 6,154,292 6,154,292 0 0.0%
Sema.NumDeclsValidated 1,197,884 1,197,884 0 0.0%
Sema.NumFunctionsTypechecked 201,866 201,866 0 0.0%
Sema.NumLazyGenericEnvironments 1,197,652 1,197,652 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 22,075 22,075 0 0.0%
Sema.NumLazyIterableDeclContexts 762,403 762,403 0 0.0%
Sema.NumTypesDeserialized 3,168,577 3,168,577 0 0.0%
Sema.NumTypesValidated 741,424 741,424 0 0.0%

@DougGregor DougGregor merged commit 690409d into swiftlang:master Jul 12, 2019
@DougGregor DougGregor deleted the more-lazy-body-synthesis branch July 12, 2019 17:07
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