Skip to content

Naive Dependency Replay #31837

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
May 21, 2020
Merged

Naive Dependency Replay #31837

merged 2 commits into from
May 21, 2020

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented May 16, 2020

Split off the notion of "recording" dependencies from the notion of
"collecting" dependencies. This corrects an oversight in the previous
design where dependency replay and recording were actually not "free" in
WMO where we actually never track dependencies. This architecture also
lays the groundwork for the removal of the referenced name trackers.

The algorithm builds upon the infrastructure for dependency sources and
sinks laid down during the cut over to request-based dependency tracking
in #30723.

The idea of the naive algorithm is this:

For a chain of requests A -> B* -> C -> D* -> ... -> L where L is a lookup
request and all starred requests are cached, once L writes into the
dependency collector, the active stack is walked and at each cache-point
the results of dependency collection are associated with the request
itself (in this example, B* and D* have all the names L found associated
with them). Subsequent evaluations of these cached requests (B* and D*
et al) will then replay the previous lookup results from L into the
active referenced name tracker. One complication: suppose the
evaluation of a cached request involves multiple downstream name
lookups. More concretely, suppose we have the following request trace:

A* -> B -> L
      |
       -> C -> L
          |
           -> D -> L
              |
               -> ...

Then A* must see the union of the results of each L. If this reminds
anyone of a union-find, that is no accident! A persistent union-find
a la Conchon and Filliatre is probably in order to help bring down peak
heap usage...

@CodaFi CodaFi requested a review from slavapestov May 16, 2020 03:20
@CodaFi
Copy link
Contributor Author

CodaFi commented May 16, 2020

@swift-ci test compiler performance

@swift-ci
Copy link
Contributor

Summary for master full

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

Regressions found (see below)

Debug-batch

debug-batch brief

Regressed (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 57,294,550,314,694 61,026,114,758,978 3,731,564,444,284 6.51% ⛔
time.swift-driver.wall 3843.0s 4037.3s 194.2s 5.05% ⛔
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,873,211,228 1,873,216,596 5,368 0.0%

debug-batch detailed

Regressed (7)
name old new delta delta_pct
AST.NumReferencedMemberNames 7,668,785 8,675,151 1,006,366 13.12% ⛔
AST.NumReferencedTopLevelNames 614,772 940,666 325,894 53.01% ⛔
Driver.ChildrenMaxRSS 259,251,697,664 262,155,593,728 2,903,896,064 1.12% ⛔
Driver.NumDriverPipePolls 100,623 104,941 4,318 4.29% ⛔
Driver.NumDriverPipeReads 91,240 95,551 4,311 4.72% ⛔
Frontend.MaxMallocUsage 1,144,242,227,496 1,169,103,420,304 24,861,192,808 2.17% ⛔
Frontend.NumInstructionsExecuted 57,294,550,314,694 61,026,114,758,978 3,731,564,444,284 6.51% ⛔
Improved (1)
name old new delta delta_pct
AST.NumSourceLinesPerSecond 3,467,913 3,284,925 -182,988 -5.28% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (231)
name old new delta delta_pct
AST.ImportSetCacheHit 1,804,843 1,804,616 -227 -0.01%
AST.ImportSetCacheMiss 389,995 389,956 -39 -0.01%
AST.ImportSetFoldHit 122,510 122,495 -15 -0.01%
AST.ImportSetFoldMiss 267,485 267,460 -25 -0.01%
AST.ModuleShadowCacheHit 3,659 3,659 0 0.0%
AST.ModuleShadowCacheMiss 1,888 1,888 0 0.0%
AST.ModuleVisibilityCacheHit 36,895 36,895 0 0.0%
AST.ModuleVisibilityCacheMiss 8,425 8,425 0 0.0%
AST.NumASTBytesAllocated 55,854,546,993 56,031,366,221 176,819,228 0.32%
AST.NumASTScopeLookups 3,645,748 3,645,549 -199 -0.01%
AST.NumBraceStmtASTScopeExpansions 642,615 642,615 0 0.0%
AST.NumBraceStmtASTScopes 642,615 642,615 0 0.0%
AST.NumDecls 146,061 146,061 0 0.0%
AST.NumDependencies 304,853 304,836 -17 -0.01%
AST.NumIterableTypeBodyASTScopeExpansions 241,114 241,113 -1 -0.0%
AST.NumIterableTypeBodyASTScopes 290,147 290,127 -20 -0.01%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 246,334 246,334 0 0.0%
AST.NumLocalTypeDecls 255 255 0 0.0%
AST.NumModuleLookupClassMember 6,993 6,993 0 0.0%
AST.NumModuleLookupValue 48,895,795 48,889,247 -6,548 -0.01%
AST.NumObjCMethods 25,367 25,367 0 0.0%
AST.NumOperators 589 589 0 0.0%
AST.NumPrecedenceGroups 93 93 0 0.0%
AST.NumReferencedDynamicNames 191 191 0 0.0%
AST.NumSourceBuffers 326,123 326,123 0 0.0%
AST.NumSourceLines 4,858,975 4,858,975 0 0.0%
AST.NumTotalClangImportedEntities 1,897,379 1,899,088 1,709 0.09%
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 29,018 29,018 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.NumProcessFailures 0 0 0 0.0%
IRGen.IRGenSourceFileRequest 27,704 27,704 0 0.0%
IRGen.IRGenWholeModuleRequest 20 20 0 0.0%
IRModule.NumGOTEntries 249,271 249,271 0 0.0%
IRModule.NumIRAliases 203,652 203,652 0 0.0%
IRModule.NumIRBasicBlocks 7,063,569 7,063,569 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,550,769 3,550,769 0 0.0%
IRModule.NumIRGlobals 3,851,014 3,851,014 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 90,718,830 90,718,830 0 0.0%
IRModule.NumIRNamedMetaData 140,120 140,120 0 0.0%
IRModule.NumIRValueSymbols 6,723,437 6,723,437 0 0.0%
LLVM.NumLLVMBytesOutput 1,873,211,228 1,873,216,596 5,368 0.0%
Parse.CodeCompletionSecondPassRequest 0 0 0 0.0%
Parse.NumFunctionsParsed 279,720 279,720 0 0.0%
Parse.NumIterableDeclContextParsed 623,761 623,757 -4 -0.0%
Parse.ParseAbstractFunctionBodyRequest 256,969 256,969 0 0.0%
Parse.ParseMembersRequest 491,009 491,005 -4 -0.0%
Parse.ParseSourceFileRequest 316,972 316,972 0 0.0%
SILGen.ParseSILModuleRequest 0 0 0 0.0%
SILGen.SILGenerationRequest 29,006 29,006 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,772,287 1,772,287 0 0.0%
SILModule.NumSILGenGlobalVariables 55,392 55,392 0 0.0%
SILModule.NumSILGenVtables 19,137 19,137 0 0.0%
SILModule.NumSILGenWitnessTables 75,903 75,903 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,611,485 2,611,485 0 0.0%
SILModule.NumSILOptGlobalVariables 57,108 57,108 0 0.0%
SILModule.NumSILOptVtables 32,429 32,429 0 0.0%
SILModule.NumSILOptWitnessTables 175,748 175,748 0 0.0%
SILOptimizer.ExecuteSILPipelineRequest 112,178 112,178 0 0.0%
Sema.AbstractGenericSignatureRequest 34,665 34,665 0 0.0%
Sema.AccessLevelRequest 12,960,169 13,029,441 69,272 0.53%
Sema.AnyObjectLookupRequest 283 283 0 0.0%
Sema.AreAllStoredPropertiesDefaultInitableRequest 22,058 22,058 0 0.0%
Sema.AttachedFunctionBuilderRequest 145 145 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 583,952 583,952 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,596,355 2,596,353 -2 -0.0%
Sema.CallerSideDefaultArgExprRequest 79,503 79,503 0 0.0%
Sema.CheckRedeclarationRequest 1,014,328 1,014,328 0 0.0%
Sema.ClassAncestryFlagsRequest 102,266 102,266 0 0.0%
Sema.ClosureHasExplicitResultRequest 93,483 93,483 0 0.0%
Sema.CollectOverriddenDeclsRequest 8,155,288 8,196,885 41,597 0.51%
Sema.CompareDeclSpecializationRequest 490,395 490,431 36 0.01%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 432 432 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 55,597 55,609 12 0.02%
Sema.DefaultArgumentExprRequest 39,907 39,907 0 0.0%
Sema.DefaultArgumentInitContextRequest 259 259 0 0.0%
Sema.DefaultDefinitionTypeRequest 8,194 8,194 0 0.0%
Sema.DefaultTypeRequest 498,455 498,455 0 0.0%
Sema.DerivativeAttrOriginalDeclRequest 0 0 0 0.0%
Sema.DifferentiableAttributeTypeCheckRequest 0 0 0 0.0%
Sema.DirectLookupRequest 34,523,918 34,540,499 16,581 0.05%
Sema.DirectOperatorLookupRequest 499,496 499,517 21 0.0%
Sema.DirectPrecedenceGroupLookupRequest 146,253 146,253 0 0.0%
Sema.DynamicallyReplacedDeclRequest 1,045,026 1,045,026 0 0.0%
Sema.EmittedMembersRequest 26,720 26,720 0 0.0%
Sema.EnumRawTypeRequest 22,941 22,941 0 0.0%
Sema.EnumRawValuesRequest 10,890 10,890 0 0.0%
Sema.ExistentialConformsToSelfRequest 11,857 11,870 13 0.11%
Sema.ExistentialTypeSupportedRequest 16,481 16,481 0 0.0%
Sema.ExpandASTScopeRequest 6,722,841 6,722,808 -33 -0.0%
Sema.ExtendedNominalRequest 499,655 499,655 0 0.0%
Sema.ExtendedTypeRequest 78,531 78,530 -1 -0.0%
Sema.FragileFunctionKindRequest 1,781,920 1,781,917 -3 -0.0%
Sema.FunctionBuilderTypeRequest 145 145 0 0.0%
Sema.FunctionOperatorRequest 51,393 51,393 0 0.0%
Sema.GenericParamListRequest 9,476,177 9,510,254 34,077 0.36%
Sema.GenericSignatureRequest 2,400,211 2,400,053 -158 -0.01%
Sema.GetDestructorRequest 27,372 27,372 0 0.0%
Sema.HasCircularInheritanceRequest 23,090 23,090 0 0.0%
Sema.HasCircularInheritedProtocolsRequest 10,422 10,422 0 0.0%
Sema.HasCircularRawValueRequest 9,296 9,296 0 0.0%
Sema.HasDefaultInitRequest 53,690 53,690 0 0.0%
Sema.HasDynamicCallableAttributeRequest 0 0 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 585,338 585,489 151 0.03%
Sema.HasImplementationOnlyImportsRequest 316,972 316,972 0 0.0%
Sema.HasMemberwiseInitRequest 20,401 20,401 0 0.0%
Sema.HasMissingDesignatedInitializersRequest 25,414 25,414 0 0.0%
Sema.HasUserDefinedDesignatedInitRequest 53,700 53,700 0 0.0%
Sema.InferredGenericSignatureRequest 164,604 164,603 -1 -0.0%
Sema.InheritedDeclsReferencedRequest 5,368,045 5,367,214 -831 -0.02%
Sema.InheritedProtocolsRequest 525,498 525,661 163 0.03%
Sema.InheritedTypeRequest 287,265 287,253 -12 -0.0%
Sema.InheritsSuperclassInitializersRequest 26,387 26,387 0 0.0%
Sema.InitKindRequest 94,704 94,704 0 0.0%
Sema.InterfaceTypeRequest 14,054,556 14,087,875 33,319 0.24%
Sema.IsABICompatibleOverrideRequest 140,119 140,119 0 0.0%
Sema.IsAccessorTransparentRequest 318,676 318,676 0 0.0%
Sema.IsCallableNominalTypeRequest 2,170 2,170 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,743,877 1,743,877 0 0.0%
Sema.IsFinalRequest 2,716,239 2,721,562 5,323 0.2%
Sema.IsGetterMutatingRequest 432,267 432,267 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,410,129 2,410,645 516 0.02%
Sema.IsObjCRequest 1,560,204 1,560,834 630 0.04%
Sema.IsSetterMutatingRequest 375,002 375,002 0 0.0%
Sema.IsStaticRequest 895,919 895,671 -248 -0.03%
Sema.LazyStoragePropertyRequest 2,497 2,497 0 0.0%
Sema.LookupAllConformancesInContextRequest 85,460 85,460 0 0.0%
Sema.LookupConformanceInModuleRequest 37,368,784 37,388,234 19,450 0.05%
Sema.LookupInModuleRequest 6,396,065 6,392,730 -3,335 -0.05%
Sema.LookupInfixOperatorRequest 83,205 83,205 0 0.0%
Sema.LookupPostfixOperatorRequest 184 184 0 0.0%
Sema.LookupPrecedenceGroupRequest 32,397 32,397 0 0.0%
Sema.LookupPrefixOperatorRequest 563 563 0 0.0%
Sema.MangleLocalTypeDeclRequest 510 510 0 0.0%
Sema.ModuleImplicitImportsRequest 10,015 10,015 0 0.0%
Sema.ModuleQualifiedLookupRequest 3,005,877 3,002,740 -3,137 -0.1%
Sema.NamedLazyMemberLoadSuccessCount 20,412,469 20,399,835 -12,634 -0.06%
Sema.NamingPatternRequest 212,831 212,829 -2 -0.0%
Sema.NeedsNewVTableEntryRequest 685,173 685,173 0 0.0%
Sema.NumAccessorBodiesSynthesized 195,750 195,750 0 0.0%
Sema.NumAccessorsSynthesized 288,736 288,736 0 0.0%
Sema.NumConformancesDeserialized 9,312,163 9,335,566 23,403 0.25%
Sema.NumConstraintScopes 31,304,579 31,306,822 2,243 0.01%
Sema.NumConstraintsConsideredForEdgeContraction 103,379,860 103,379,941 81 0.0%
Sema.NumCrossImportsChecked 0 0 0 0.0%
Sema.NumCrossImportsFound 0 0 0 0.0%
Sema.NumCyclicOneWayComponentsCollapsed 269 269 0 0.0%
Sema.NumDeclsDeserialized 72,041,032 72,174,834 133,802 0.19%
Sema.NumDeclsTypechecked 1,462,821 1,462,821 0 0.0%
Sema.NumGenericSignatureBuilders 1,297,292 1,299,980 2,688 0.21%
Sema.NumLazyIterableDeclContexts 8,268,506 8,271,313 2,807 0.03%
Sema.NumLazyRequirementSignatures 787,058 787,340 282 0.04%
Sema.NumLazyRequirementSignaturesLoaded 585,437 585,669 232 0.04%
Sema.NumLeafScopes 19,969,750 19,971,745 1,995 0.01%
Sema.NumTypesDeserialized 22,450,126 22,482,918 32,792 0.15%
Sema.NumTypesValidated 648,596 648,594 -2 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 5,084,382 5,076,695 -7,687 -0.15%
Sema.OpaqueReadOwnershipRequest 273,127 273,127 0 0.0%
Sema.OpaqueResultTypeRequest 178 178 0 0.0%
Sema.OperatorPrecedenceGroupRequest 749 749 0 0.0%
Sema.OverriddenDeclsRequest 2,559,089 2,567,726 8,637 0.34%
Sema.ParamSpecifierRequest 1,223,647 1,223,646 -1 -0.0%
Sema.PatternBindingEntryRequest 471,038 471,036 -2 -0.0%
Sema.PatternTypeRequest 546,756 546,754 -2 -0.0%
Sema.PreCheckFunctionBuilderRequest 296 296 0 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 578,000 578,000 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 583,952 583,952 0 0.0%
Sema.PropertyWrapperLValuenessRequest 203 203 0 0.0%
Sema.PropertyWrapperMutabilityRequest 616,925 616,925 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 78 78 0 0.0%
Sema.ProtocolRequiresClassRequest 36,710 36,713 3 0.01%
Sema.ProvideDefaultImplForRequest 8,155,288 8,196,885 41,597 0.51%
Sema.QualifiedLookupRequest 5,584,913 5,589,843 4,930 0.09%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 113,354 113,353 -1 -0.0%
Sema.RequirementSignatureRequest 638,749 638,948 199 0.03%
Sema.RequiresOpaqueAccessorsRequest 1,340,103 1,340,103 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 262,365 262,365 0 0.0%
Sema.ResolveEffectiveMemberwiseInitRequest 0 0 0 0.0%
Sema.ResolveImplicitMemberRequest 387,485 388,038 553 0.14%
Sema.ResolveProtocolNameRequest 0 0 0 0.0%
Sema.ResolveTypeEraserTypeRequest 0 0 0 0.0%
Sema.ResolveTypeRequest 3,375,918 3,375,911 -7 -0.0%
Sema.ResultTypeRequest 651,605 651,605 0 0.0%
Sema.RootAndResultTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.RootTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.SPIGroupsRequest 14,657,126 14,701,584 44,458 0.3%
Sema.ScopedImportLookupRequest 1,076 1,076 0 0.0%
Sema.SelfAccessKindRequest 614,507 614,294 -213 -0.03%
Sema.SelfBoundsFromWhereClauseRequest 1,623,932 1,621,659 -2,273 -0.14%
Sema.SetterAccessLevelRequest 148,281 148,281 0 0.0%
Sema.SimpleDidSetRequest 2,623,524 2,627,293 3,769 0.14%
Sema.StorageImplInfoRequest 1,480,180 1,480,180 0 0.0%
Sema.StoredPropertiesAndMissingMembersRequest 32,056 32,056 0 0.0%
Sema.StoredPropertiesRequest 325,444 325,444 0 0.0%
Sema.StructuralTypeRequest 2,037 2,037 0 0.0%
Sema.SuperclassDeclRequest 414,163 414,387 224 0.05%
Sema.SuperclassTypeRequest 54,397 54,397 0 0.0%
Sema.SynthesizeAccessorRequest 288,736 288,736 0 0.0%
Sema.SynthesizeDefaultInitRequest 5,016 5,016 0 0.0%
Sema.SynthesizeMemberwiseInitRequest 3,565 3,565 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 548,128 548,128 0 0.0%
Sema.TypeCheckSourceFileRequest 28,024 28,024 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 29,788 29,788 0 0.0%
Sema.TypeEraserHasViableInitRequest 0 0 0 0.0%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.TypeWitnessRequest 9,116 9,116 0 0.0%
Sema.USRGenerationRequest 9,568,141 9,607,314 39,173 0.41%
Sema.UnderlyingTypeDeclsReferencedRequest 268,348 268,221 -127 -0.05%
Sema.UnderlyingTypeRequest 34,774 34,774 0 0.0%
Sema.UnqualifiedLookupRequest 3,795,752 3,795,553 -199 -0.01%
Sema.ValidatePrecedenceGroupRequest 183,650 183,650 0 0.0%
Sema.ValueWitnessRequest 65,861 65,861 0 0.0%
TBDGen.GenerateTBDRequest 27,724 27,724 0 0.0%

Release

release brief

Regressed (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 54,632,642,730,760 56,150,611,438,096 1,517,968,707,336 2.78% ⛔
time.swift-driver.wall 6225.4s 6473.1s 247.7s 3.98% ⛔
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,875,604,494 1,875,604,394 -100 -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) (17)
name old new delta delta_pct
AST.NumLoadedModules 27,540 27,540 0 0.0%
AST.NumTotalClangImportedEntities 474,358 474,358 0 0.0%
IRModule.NumIRBasicBlocks 4,972,663 4,972,663 0 0.0%
IRModule.NumIRFunctions 2,877,666 2,877,666 0 0.0%
IRModule.NumIRGlobals 3,386,079 3,386,079 0 0.0%
IRModule.NumIRInsts 50,140,702 50,140,702 0 0.0%
IRModule.NumIRValueSymbols 5,894,064 5,894,064 0 0.0%
LLVM.NumLLVMBytesOutput 1,875,604,494 1,875,604,394 -100 -0.0%
SILModule.NumSILGenFunctions 1,238,653 1,238,653 0 0.0%
SILModule.NumSILOptFunctions 1,038,075 1,038,075 0 0.0%
Sema.NumConformancesDeserialized 3,580,159 3,580,159 0 0.0%
Sema.NumConstraintScopes 31,010,592 31,010,592 0 0.0%
Sema.NumDeclsDeserialized 11,237,891 11,237,891 0 0.0%
Sema.NumGenericSignatureBuilders 279,216 279,216 0 0.0%
Sema.NumLazyIterableDeclContexts 1,402,856 1,402,856 0 0.0%
Sema.NumTypesDeserialized 5,436,544 5,436,544 0 0.0%
Sema.NumTypesValidated 495,108 495,108 0 0.0%

llvm::SaveAndRestore<bool> restore(isRecording, true);
scratch = {};
rec(*this);
for (const auto &request : stack) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if instead of recording a dependency in each request on the stack, we only added them to the innermost request. Then upon completing a request (or fulfilling it from the cache), we add all of its entries to the next innermost request, and so on. This should be more efficient in the case where you add duplicate dependencies, because you will consolidate the dupes once instead of re-adding them at each level.

@slavapestov
Copy link
Contributor

I'm puzzled at the wall time regression in release builds. I thought we don't write reference dependencies when building WMO, so we should skip this entire code path, no?

@CodaFi
Copy link
Contributor Author

CodaFi commented May 19, 2020

Tracking and replay still occurs, it just never writes into anything. It's something I want to fix by removing the referenced name trackers altogether in the long run. In the short term, we can avoid doing work here by adding a mode bit that turns off evaluator dependency tracking in WMO.

@CodaFi
Copy link
Contributor Author

CodaFi commented May 19, 2020

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

Summary for master full

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

Regressions found (see below)

Debug-batch

debug-batch brief

Regressed (2)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 73,712,666,878,458 78,057,752,982,646 4,345,086,104,188 5.89% ⛔
time.swift-driver.wall 6209.7s 6449.7s 240.1s 3.87% ⛔
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,872,884,416 1,872,874,452 -9,964 -0.0%

debug-batch detailed

Regressed (6)
name old new delta delta_pct
AST.NumReferencedMemberNames 7,723,619 8,739,413 1,015,794 13.15% ⛔
AST.NumReferencedTopLevelNames 615,824 953,358 337,534 54.81% ⛔
Driver.NumDriverPipePolls 68,805 69,713 908 1.32% ⛔
Driver.NumDriverPipeReads 55,341 56,247 906 1.64% ⛔
Frontend.MaxMallocUsage 1,683,321,173,216 1,714,453,353,624 31,132,180,408 1.85% ⛔
Frontend.NumInstructionsExecuted 73,712,666,878,458 78,057,752,982,646 4,345,086,104,188 5.89% ⛔
Improved (1)
name old new delta delta_pct
AST.NumSourceLinesPerSecond 2,760,078 2,616,656 -143,422 -5.2% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (233)
name old new delta delta_pct
AST.ImportSetCacheHit 2,008,749 2,008,486 -263 -0.01%
AST.ImportSetCacheMiss 576,557 576,534 -23 -0.0%
AST.ImportSetFoldHit 179,036 179,030 -6 -0.0%
AST.ImportSetFoldMiss 397,521 397,504 -17 -0.0%
AST.ModuleShadowCacheHit 3,739 3,739 0 0.0%
AST.ModuleShadowCacheMiss 1,986 1,986 0 0.0%
AST.ModuleVisibilityCacheHit 41,675 41,675 0 0.0%
AST.ModuleVisibilityCacheMiss 10,561 10,561 0 0.0%
AST.NumASTBytesAllocated 74,688,117,642 74,618,208,116 -69,909,526 -0.09%
AST.NumASTScopeLookups 4,471,122 4,471,031 -91 -0.0%
AST.NumBraceStmtASTScopeExpansions 650,431 650,431 0 0.0%
AST.NumBraceStmtASTScopes 650,431 650,431 0 0.0%
AST.NumDecls 146,061 146,061 0 0.0%
AST.NumDependencies 447,309 447,359 50 0.01%
AST.NumIterableTypeBodyASTScopeExpansions 288,960 288,958 -2 -0.0%
AST.NumIterableTypeBodyASTScopes 372,294 372,275 -19 -0.01%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 365,013 365,013 0 0.0%
AST.NumLocalTypeDecls 255 255 0 0.0%
AST.NumModuleLookupClassMember 6,993 6,993 0 0.0%
AST.NumModuleLookupValue 56,922,645 56,911,631 -11,014 -0.02%
AST.NumObjCMethods 25,367 25,367 0 0.0%
AST.NumOperators 589 589 0 0.0%
AST.NumPrecedenceGroups 93 93 0 0.0%
AST.NumReferencedDynamicNames 191 191 0 0.0%
AST.NumSourceBuffers 603,729 603,729 0 0.0%
AST.NumSourceLines 4,858,975 4,858,975 0 0.0%
AST.NumTotalClangImportedEntities 2,452,153 2,447,720 -4,433 -0.18%
Driver.ChildrenMaxRSS 276,392,501,248 278,043,138,048 1,650,636,800 0.6%
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 29,018 29,018 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.NumProcessFailures 0 0 0 0.0%
IRGen.IRGenSourceFileRequest 27,704 27,704 0 0.0%
IRGen.IRGenWholeModuleRequest 20 20 0 0.0%
IRModule.NumGOTEntries 249,271 249,271 0 0.0%
IRModule.NumIRAliases 203,652 203,652 0 0.0%
IRModule.NumIRBasicBlocks 7,063,569 7,063,569 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,550,769 3,550,769 0 0.0%
IRModule.NumIRGlobals 3,850,996 3,850,996 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 90,718,830 90,718,830 0 0.0%
IRModule.NumIRNamedMetaData 140,120 140,120 0 0.0%
IRModule.NumIRValueSymbols 6,723,431 6,723,431 0 0.0%
LLVM.NumLLVMBytesOutput 1,872,884,416 1,872,874,452 -9,964 -0.0%
Parse.CodeCompletionSecondPassRequest 0 0 0 0.0%
Parse.NumFunctionsParsed 280,363 280,363 0 0.0%
Parse.NumIterableDeclContextParsed 966,615 966,615 0 0.0%
Parse.ParseAbstractFunctionBodyRequest 257,915 257,915 0 0.0%
Parse.ParseMembersRequest 795,490 795,490 0 0.0%
Parse.ParseSourceFileRequest 593,126 593,126 0 0.0%
SILGen.ParseSILModuleRequest 0 0 0 0.0%
SILGen.SILGenerationRequest 29,006 29,006 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,772,287 1,772,287 0 0.0%
SILModule.NumSILGenGlobalVariables 55,392 55,392 0 0.0%
SILModule.NumSILGenVtables 19,137 19,137 0 0.0%
SILModule.NumSILGenWitnessTables 75,903 75,903 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,611,485 2,611,485 0 0.0%
SILModule.NumSILOptGlobalVariables 57,108 57,108 0 0.0%
SILModule.NumSILOptVtables 32,429 32,429 0 0.0%
SILModule.NumSILOptWitnessTables 175,748 175,748 0 0.0%
SILOptimizer.ExecuteSILPipelineRequest 112,178 112,178 0 0.0%
Sema.AbstractGenericSignatureRequest 39,702 39,702 0 0.0%
Sema.AccessLevelRequest 16,604,345 16,563,317 -41,028 -0.25%
Sema.AnyObjectLookupRequest 283 283 0 0.0%
Sema.AreAllStoredPropertiesDefaultInitableRequest 24,616 24,616 0 0.0%
Sema.AttachedFunctionBuilderRequest 181 181 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 591,652 591,652 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,723,669 2,723,669 0 0.0%
Sema.CallerSideDefaultArgExprRequest 79,503 79,503 0 0.0%
Sema.CheckInconsistentImplementationOnlyImportsRequest 13,196 13,196 0 0.0%
Sema.CheckRedeclarationRequest 1,014,210 1,014,210 0 0.0%
Sema.ClassAncestryFlagsRequest 119,418 119,418 0 0.0%
Sema.ClosureHasExplicitResultRequest 93,515 93,515 0 0.0%
Sema.CollectOverriddenDeclsRequest 10,750,861 10,710,315 -40,546 -0.38%
Sema.CompareDeclSpecializationRequest 514,961 514,587 -374 -0.07%
Sema.CursorInfoRequest 0 0 0 0.0%
Sema.CustomAttrNominalRequest 501 501 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 60,867 60,890 23 0.04%
Sema.DefaultArgumentExprRequest 39,907 39,907 0 0.0%
Sema.DefaultArgumentInitContextRequest 259 259 0 0.0%
Sema.DefaultDefinitionTypeRequest 8,722 8,722 0 0.0%
Sema.DefaultTypeRequest 502,266 502,266 0 0.0%
Sema.DerivativeAttrOriginalDeclRequest 0 0 0 0.0%
Sema.DifferentiableAttributeTypeCheckRequest 0 0 0 0.0%
Sema.DirectLookupRequest 36,698,263 36,683,122 -15,141 -0.04%
Sema.DirectOperatorLookupRequest 593,641 593,308 -333 -0.06%
Sema.DirectPrecedenceGroupLookupRequest 147,073 147,073 0 0.0%
Sema.DynamicallyReplacedDeclRequest 1,108,433 1,108,433 0 0.0%
Sema.EmittedMembersRequest 28,997 28,997 0 0.0%
Sema.EnumRawTypeRequest 27,238 27,238 0 0.0%
Sema.EnumRawValuesRequest 10,961 10,961 0 0.0%
Sema.ExistentialConformsToSelfRequest 14,509 14,495 -14 -0.1%
Sema.ExistentialTypeSupportedRequest 18,521 18,521 0 0.0%
Sema.ExpandASTScopeRequest 8,094,283 8,094,247 -36 -0.0%
Sema.ExtendedNominalRequest 926,554 926,554 0 0.0%
Sema.ExtendedTypeRequest 87,562 87,561 -1 -0.0%
Sema.FragileFunctionKindRequest 1,967,705 1,967,700 -5 -0.0%
Sema.FunctionBuilderTypeRequest 181 181 0 0.0%
Sema.FunctionOperatorRequest 74,345 74,345 0 0.0%
Sema.GenericParamListRequest 12,165,467 12,140,724 -24,743 -0.2%
Sema.GenericSignatureRequest 2,886,599 2,885,204 -1,395 -0.05%
Sema.GetDestructorRequest 29,504 29,504 0 0.0%
Sema.HasCircularInheritanceRequest 24,552 24,552 0 0.0%
Sema.HasCircularInheritedProtocolsRequest 10,674 10,674 0 0.0%
Sema.HasCircularRawValueRequest 9,296 9,296 0 0.0%
Sema.HasDefaultInitRequest 59,781 59,781 0 0.0%
Sema.HasDynamicCallableAttributeRequest 0 0 0 0.0%
Sema.HasDynamicMemberLookupAttributeRequest 695,723 695,680 -43 -0.01%
Sema.HasImplementationOnlyImportsRequest 593,126 593,126 0 0.0%
Sema.HasMemberwiseInitRequest 21,772 21,772 0 0.0%
Sema.HasMissingDesignatedInitializersRequest 27,541 27,541 0 0.0%
Sema.HasUserDefinedDesignatedInitRequest 59,792 59,792 0 0.0%
Sema.InferredGenericSignatureRequest 192,813 192,809 -4 -0.0%
Sema.InheritedDeclsReferencedRequest 6,766,048 6,758,403 -7,645 -0.11%
Sema.InheritedProtocolsRequest 710,916 710,819 -97 -0.01%
Sema.InheritedTypeRequest 326,394 326,335 -59 -0.02%
Sema.InheritsSuperclassInitializersRequest 30,271 30,271 0 0.0%
Sema.InitKindRequest 102,608 102,608 0 0.0%
Sema.InterfaceTypeRequest 17,361,177 17,330,299 -30,878 -0.18%
Sema.IsABICompatibleOverrideRequest 141,210 141,210 0 0.0%
Sema.IsAccessorTransparentRequest 330,467 330,467 0 0.0%
Sema.IsCallableNominalTypeRequest 2,170 2,170 0 0.0%
Sema.IsDeclApplicableRequest 0 0 0 0.0%
Sema.IsDynamicRequest 1,819,286 1,819,286 0 0.0%
Sema.IsFinalRequest 3,159,295 3,154,128 -5,167 -0.16%
Sema.IsGetterMutatingRequest 453,282 453,282 0 0.0%
Sema.IsImplicitlyUnwrappedOptionalRequest 2,572,491 2,571,566 -925 -0.04%
Sema.IsObjCRequest 1,676,842 1,676,711 -131 -0.01%
Sema.IsSetterMutatingRequest 385,315 385,315 0 0.0%
Sema.IsStaticRequest 988,865 988,746 -119 -0.01%
Sema.LazyStoragePropertyRequest 3,005 3,005 0 0.0%
Sema.LookupAllConformancesInContextRequest 85,535 85,535 0 0.0%
Sema.LookupConformanceInModuleRequest 39,368,529 39,361,716 -6,813 -0.02%
Sema.LookupInModuleRequest 7,868,933 7,859,659 -9,274 -0.12%
Sema.LookupInfixOperatorRequest 98,186 98,186 0 0.0%
Sema.LookupPostfixOperatorRequest 215 215 0 0.0%
Sema.LookupPrecedenceGroupRequest 32,647 32,647 0 0.0%
Sema.LookupPrefixOperatorRequest 716 716 0 0.0%
Sema.MangleLocalTypeDeclRequest 510 510 0 0.0%
Sema.ModuleImplicitImportsRequest 14,478 14,478 0 0.0%
Sema.ModuleQualifiedLookupRequest 3,694,196 3,685,009 -9,187 -0.25%
Sema.NamedLazyMemberLoadSuccessCount 23,473,735 23,471,258 -2,477 -0.01%
Sema.NamingPatternRequest 250,398 250,398 0 0.0%
Sema.NeedsNewVTableEntryRequest 721,869 721,869 0 0.0%
Sema.NumAccessorBodiesSynthesized 195,812 195,812 0 0.0%
Sema.NumAccessorsSynthesized 308,404 308,404 0 0.0%
Sema.NumConformancesDeserialized 11,732,293 11,717,039 -15,254 -0.13%
Sema.NumConstraintScopes 31,477,598 31,476,075 -1,523 -0.0%
Sema.NumConstraintsConsideredForEdgeContraction 103,433,508 103,432,966 -542 -0.0%
Sema.NumCrossImportsChecked 0 0 0 0.0%
Sema.NumCrossImportsFound 0 0 0 0.0%
Sema.NumCyclicOneWayComponentsCollapsed 269 269 0 0.0%
Sema.NumDeclsDeserialized 93,503,681 93,377,463 -126,218 -0.13%
Sema.NumDeclsTypechecked 1,462,619 1,462,619 0 0.0%
Sema.NumGenericSignatureBuilders 1,652,691 1,651,102 -1,589 -0.1%
Sema.NumLazyIterableDeclContexts 11,063,574 11,059,451 -4,123 -0.04%
Sema.NumLazyRequirementSignatures 1,108,165 1,108,077 -88 -0.01%
Sema.NumLazyRequirementSignaturesLoaded 793,432 793,310 -122 -0.02%
Sema.NumLeafScopes 20,114,894 20,113,665 -1,229 -0.01%
Sema.NumTypesDeserialized 28,679,542 28,649,987 -29,555 -0.1%
Sema.NumTypesValidated 687,199 687,199 0 0.0%
Sema.NumUnloadedLazyIterableDeclContexts 6,994,482 6,997,345 2,863 0.04%
Sema.OpaqueReadOwnershipRequest 294,350 294,350 0 0.0%
Sema.OpaqueResultTypeRequest 182 182 0 0.0%
Sema.OperatorPrecedenceGroupRequest 749 749 0 0.0%
Sema.OverriddenDeclsRequest 3,013,060 3,007,082 -5,978 -0.2%
Sema.ParamSpecifierRequest 1,348,684 1,348,683 -1 -0.0%
Sema.PatternBindingEntryRequest 510,393 510,393 0 0.0%
Sema.PatternTypeRequest 586,126 586,126 0 0.0%
Sema.PreCheckFunctionBuilderRequest 296 296 0 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 584,855 584,855 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 591,652 591,652 0 0.0%
Sema.PropertyWrapperLValuenessRequest 203 203 0 0.0%
Sema.PropertyWrapperMutabilityRequest 640,000 640,000 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 107 107 0 0.0%
Sema.ProtocolRequiresClassRequest 46,052 46,022 -30 -0.07%
Sema.ProvideDefaultImplForRequest 10,750,861 10,710,315 -40,546 -0.38%
Sema.QualifiedLookupRequest 6,108,496 6,106,245 -2,251 -0.04%
Sema.RangeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 120,800 120,799 -1 -0.0%
Sema.RequirementSignatureRequest 863,810 863,625 -185 -0.02%
Sema.RequiresOpaqueAccessorsRequest 1,371,205 1,371,205 0 0.0%
Sema.RequiresOpaqueModifyCoroutineRequest 284,183 284,183 0 0.0%
Sema.ResolveEffectiveMemberwiseInitRequest 0 0 0 0.0%
Sema.ResolveImplicitMemberRequest 420,593 420,491 -102 -0.02%
Sema.ResolveProtocolNameRequest 0 0 0 0.0%
Sema.ResolveTypeEraserTypeRequest 0 0 0 0.0%
Sema.ResolveTypeRequest 3,768,571 3,768,552 -19 -0.0%
Sema.ResultTypeRequest 717,718 717,716 -2 -0.0%
Sema.RootAndResultTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.RootTypeOfKeypathDynamicMemberRequest 0 0 0 0.0%
Sema.SPIGroupsRequest 19,061,529 19,017,142 -44,387 -0.23%
Sema.ScopedImportLookupRequest 1,076 1,076 0 0.0%
Sema.SelfAccessKindRequest 691,448 691,347 -101 -0.01%
Sema.SelfBoundsFromWhereClauseRequest 2,028,935 2,027,399 -1,536 -0.08%
Sema.SetterAccessLevelRequest 152,213 152,213 0 0.0%
Sema.SimpleDidSetRequest 3,233,984 3,225,865 -8,119 -0.25%
Sema.StorageImplInfoRequest 1,536,129 1,536,129 0 0.0%
Sema.StoredPropertiesAndMissingMembersRequest 34,808 34,808 0 0.0%
Sema.StoredPropertiesRequest 398,053 398,053 0 0.0%
Sema.StructuralTypeRequest 2,340 2,340 0 0.0%
Sema.SuperclassDeclRequest 538,755 538,652 -103 -0.02%
Sema.SuperclassTypeRequest 63,098 63,098 0 0.0%
Sema.SynthesizeAccessorRequest 308,404 308,404 0 0.0%
Sema.SynthesizeDefaultInitRequest 5,680 5,680 0 0.0%
Sema.SynthesizeMemberwiseInitRequest 3,791 3,791 0 0.0%
Sema.TypeCheckFunctionBodyUntilRequest 548,128 548,128 0 0.0%
Sema.TypeCheckSourceFileRequest 28,024 28,024 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 31,848 31,847 -1 -0.0%
Sema.TypeEraserHasViableInitRequest 0 0 0 0.0%
Sema.TypeRelationCheckRequest 0 0 0 0.0%
Sema.TypeWitnessRequest 10,288 10,287 -1 -0.01%
Sema.USRGenerationRequest 12,320,394 12,277,987 -42,407 -0.34%
Sema.UnderlyingTypeDeclsReferencedRequest 337,881 337,200 -681 -0.2%
Sema.UnderlyingTypeRequest 40,336 40,336 0 0.0%
Sema.UnqualifiedLookupRequest 4,624,110 4,624,019 -91 -0.0%
Sema.ValidatePrecedenceGroupRequest 183,900 183,900 0 0.0%
Sema.ValueWitnessRequest 72,012 72,012 0 0.0%
TBDGen.GenerateTBDRequest 27,724 27,724 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 55,103,313,010,471 55,537,207,695,474 433,894,685,003 0.79%
LLVM.NumLLVMBytesOutput 1,875,700,986 1,875,704,746 3,760 0.0%
time.swift-driver.wall 10136.6s 10236.9s 100.3s 0.99%

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) (17)
name old new delta delta_pct
AST.NumLoadedModules 27,540 27,540 0 0.0%
AST.NumTotalClangImportedEntities 474,358 474,358 0 0.0%
IRModule.NumIRBasicBlocks 4,972,663 4,972,663 0 0.0%
IRModule.NumIRFunctions 2,877,666 2,877,666 0 0.0%
IRModule.NumIRGlobals 3,386,079 3,386,079 0 0.0%
IRModule.NumIRInsts 50,140,702 50,140,702 0 0.0%
IRModule.NumIRValueSymbols 5,894,064 5,894,064 0 0.0%
LLVM.NumLLVMBytesOutput 1,875,700,986 1,875,704,746 3,760 0.0%
SILModule.NumSILGenFunctions 1,238,653 1,238,653 0 0.0%
SILModule.NumSILOptFunctions 1,038,075 1,038,075 0 0.0%
Sema.NumConformancesDeserialized 3,580,159 3,580,159 0 0.0%
Sema.NumConstraintScopes 31,010,578 31,010,585 7 0.0%
Sema.NumDeclsDeserialized 11,237,891 11,237,891 0 0.0%
Sema.NumGenericSignatureBuilders 279,216 279,216 0 0.0%
Sema.NumLazyIterableDeclContexts 1,402,856 1,402,856 0 0.0%
Sema.NumTypesDeserialized 5,436,544 5,436,544 0 0.0%
Sema.NumTypesValidated 495,108 495,108 0 0.0%

Finish off private intransitive dependencies with an implementation of
dependency replay.

For the sake of illustration, imagine a chain of requests

A -> B -> C -> ...

Supposing each request is never cached, then every invocation of the
compiler with the same inputs will always kick off the exact same set of
requests. For the purposes of dependency tracking, that also means every
single lookup request will run without issue, and all dependencies will
be accurately reported. But we live in a world with cached requests.
Suppose request B* is cached. The first time we encounter that request,
its evaluation order looks identical:

A -> B* -> C -> ...

If we are in a mode that compiles single primaries, this is not
a problem because every request graph will look like this.
But if we are in a mode where we are compiling multiple primaries, then
subsequent request graphs will *actually* hit the cache and never
execute request C or any of its dependent computations!

A -> B*

Supposing C was a lookup request, that means the name(s) looked up
downstream of B* will *never* be recorded in the referenced name tracker
which can lead to miscompilation. Note that this is not a problem
inherent to the design of the request evaluator - caches in the compiler
have *always* hidden dependent lookups. In fact, the request evaluator
provides us our first opportunity to resolve this correctness bug!
@CodaFi
Copy link
Contributor Author

CodaFi commented May 20, 2020

At least there's no regressions in WMO with this version. Alright, let's ship it.

@CodaFi CodaFi marked this pull request as ready for review May 20, 2020 17:42
@CodaFi CodaFi changed the title [Experiment] Naive Dependency Replay Naive Dependency Replay May 20, 2020
@CodaFi
Copy link
Contributor Author

CodaFi commented May 20, 2020

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e65d31af0a6d5a7ed38658e643b03f3d71cda152

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e65d31af0a6d5a7ed38658e643b03f3d71cda152

@CodaFi
Copy link
Contributor Author

CodaFi commented May 20, 2020

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e65d31af0a6d5a7ed38658e643b03f3d71cda152

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e65d31af0a6d5a7ed38658e643b03f3d71cda152

Split off the notion of "recording" dependencies from the notion of
"collecting" dependencies. This corrects an oversight in the previous
design where dependency replay and recording were actually not "free" in
WMO where we actually never track dependencies. This architecture also
lays the groundwork for the removal of the referenced name trackers.

The algorithm builds upon the infrastructure for dependency sources and
sinks laid down during the cut over to request-based dependency tracking
in swiftlang#30723.

The idea of the naive algorithm is this:

For a chain of requests A -> B* -> C -> D* -> ... -> L where L is a lookup
request and all starred requests are cached, once L writes into the
dependency collector, the active stack is walked and at each cache-point
the results of dependency collection are associated with the request
itself (in this example, B* and D* have all the names L found associated
with them). Subsequent evaluations of these cached requests (B* and D*
et al) will then *replay* the previous lookup results from L into the
active referenced name tracker. One complication is, suppose the
evaluation of a cached request involves multiple downstream name
lookups. More concretely, suppose we have the following request trace:

A* -> B -> L
      |
       -> C -> L
          |
           -> D -> L
              |
               -> ...

Then A* must see the union of the results of each L. If this reminds
anyone of a union-find, that is no accident! A persistent union-find
a la Conchon and Filliatre is probably in order to help bring down peak
heap usage...
@CodaFi
Copy link
Contributor Author

CodaFi commented May 20, 2020

Ack, wrong conditional - cut off all dependency writing except with private dependencies enabled. We're not trying to go that far.

@swift-ci test

@CodaFi
Copy link
Contributor Author

CodaFi commented May 20, 2020

@swift-ci test Windows

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0a7929e

@CodaFi
Copy link
Contributor Author

CodaFi commented May 21, 2020

@swift-ci clean test Linux

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0a7929e

@CodaFi
Copy link
Contributor Author

CodaFi commented May 21, 2020

@swift-ci smoke test macOS

@CodaFi
Copy link
Contributor Author

CodaFi commented May 21, 2020

@CodaFi CodaFi merged commit d93f44a into swiftlang:master May 21, 2020
@CodaFi CodaFi deleted the record-scratch branch May 21, 2020 05:12
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