Skip to content

Remove useBridgedNSErrorConformances() #24872

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

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented May 17, 2019

Follow-up to #24267 and #24665.

Now that Sema builds fully type-checked bodies for accessors, we can remove Sema's explicit checking of _StoredBridgedNSError conformances in favor of SILGen trigger it via the lazy resolver mechanism.

The only missing piece was then to change how SILGen emits external definitions; we now do it all on-demand, instead of walking the external definitions list, which solves an order dependency where definitions that were added to the external definitions list after SILGen had already walked the list would not be emitted at all.

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor 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, Prelude_UIKit, 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 30,842,427,850,506 30,554,278,629,470 -288,149,221,036 -0.93%
LLVM.NumLLVMBytesOutput 1,162,202,608 1,162,194,520 -8,088 -0.0%
time.swift-driver.wall 2818.6s 2796.0s -22.6s -0.8%

debug-batch detailed

Regressed (1)
name old new delta delta_pct
AST.NumSourceLinesPerSecond 2,401,095 2,449,866 48,771 2.03% ⛔
Improved (12)
name old new delta delta_pct
AST.NumTotalClangImportedEntities 4,570,195 4,497,305 -72,890 -1.59% ✅
Driver.NumDriverPipePolls 179,706 176,192 -3,514 -1.96% ✅
Driver.NumDriverPipeReads 193,835 190,902 -2,933 -1.51% ✅
Sema.ExtendedNominalRequest 4,078,396 3,790,803 -287,593 -7.05% ✅
Sema.InheritedDeclsReferencedRequest 4,564,249 3,916,017 -648,232 -14.2% ✅
Sema.NumConformancesDeserialized 6,798,846 6,470,688 -328,158 -4.83% ✅
Sema.NumDeclsDeserialized 51,838,661 51,175,832 -662,829 -1.28% ✅
Sema.NumLazyIterableDeclContexts 7,203,785 6,785,342 -418,443 -5.81% ✅
Sema.NumUnloadedLazyIterableDeclContexts 4,746,991 4,339,375 -407,616 -8.59% ✅
Sema.SelfBoundsFromWhereClauseRequest 6,581,400 5,105,348 -1,476,052 -22.43% ✅
Sema.USRGenerationRequest 13,069,548 12,921,407 -148,141 -1.13% ✅
Sema.UnderlyingTypeDeclsReferencedRequest 176,801 169,997 -6,804 -3.85% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (96)
name old new delta delta_pct
AST.NumASTBytesAllocated 72,275,278,300 71,938,970,698 -336,307,602 -0.47%
AST.NumDecls 94,340 94,340 0 0.0%
AST.NumDependencies 212,333 212,338 5 0.0%
AST.NumImportedExternalDefinitions 1,188,781 1,188,111 -670 -0.06%
AST.NumInfixOperators 35,655 35,655 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 253,766 253,766 0 0.0%
AST.NumLocalTypeDecls 123 123 0 0.0%
AST.NumObjCMethods 15,429 15,429 0 0.0%
AST.NumPostfixOperators 18 18 0 0.0%
AST.NumPrecedenceGroups 17,426 17,426 0 0.0%
AST.NumPrefixOperators 90 90 0 0.0%
AST.NumReferencedDynamicNames 122 122 0 0.0%
AST.NumReferencedMemberNames 4,130,723 4,130,723 0 0.0%
AST.NumReferencedTopLevelNames 322,377 322,377 0 0.0%
AST.NumSourceBuffers 404,375 404,375 0 0.0%
AST.NumSourceLines 3,161,007 3,161,007 0 0.0%
AST.NumStoredPropertiesQueries 9,355,594 9,355,786 192 0.0%
Driver.ChildrenMaxRSS 111,679,070,208 111,674,628,096 -4,442,112 -0.0%
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,246 19,246 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 738,735,126,448 735,580,562,304 -3,154,564,144 -0.43%
Frontend.NumInstructionsExecuted 30,842,427,850,506 30,554,278,629,470 -288,149,221,036 -0.93%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 121,143 121,143 0 0.0%
IRModule.NumIRBasicBlocks 4,666,837 4,666,837 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 2,121,013 2,121,017 4 0.0%
IRModule.NumIRGlobals 2,224,308 2,224,308 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 61,382,680 61,382,649 -31 -0.0%
IRModule.NumIRNamedMetaData 93,520 93,520 0 0.0%
IRModule.NumIRValueSymbols 3,877,362 3,877,366 4 0.0%
LLVM.NumLLVMBytesOutput 1,162,202,608 1,162,194,520 -8,088 -0.0%
Parse.NumFunctionsParsed 173,853 173,853 0 0.0%
Parse.NumIterableDeclContextParsed 1,182,982 1,182,982 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,095,234 1,095,223 -11 -0.0%
SILModule.NumSILGenGlobalVariables 41,536 41,536 0 0.0%
SILModule.NumSILGenVtables 12,415 12,415 0 0.0%
SILModule.NumSILGenWitnessTables 46,295 46,295 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 1,557,871 1,557,867 -4 -0.0%
SILModule.NumSILOptGlobalVariables 42,431 42,431 0 0.0%
SILModule.NumSILOptVtables 20,589 20,589 0 0.0%
SILModule.NumSILOptWitnessTables 101,731 101,731 0 0.0%
Sema.AccessLevelRequest 2,835,495 2,834,021 -1,474 -0.05%
Sema.AttachedPropertyDelegateRequest 1,421,863 1,421,446 -417 -0.03%
Sema.AttachedPropertyDelegateTypeRequest 275,931 275,891 -40 -0.01%
Sema.CustomAttrNominalRequest 0 0 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 63,573 63,563 -10 -0.02%
Sema.DefaultDefinitionTypeRequest 5,928 5,928 0 0.0%
Sema.DefaultTypeRequest 344,971 344,971 0 0.0%
Sema.EnumRawTypeRequest 18,228 18,074 -154 -0.84%
Sema.InheritedTypeRequest 240,448 240,102 -346 -0.14%
Sema.IsDynamicRequest 2,203,951 2,203,092 -859 -0.04%
Sema.IsFinalRequest 4,004,679 3,988,548 -16,131 -0.4%
Sema.IsObjCRequest 1,934,427 1,934,283 -144 -0.01%
Sema.MangleLocalTypeDeclRequest 246 246 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 23,046 22,948 -98 -0.43%
Sema.NamedLazyMemberLoadSuccessCount 21,085,268 21,137,627 52,359 0.25%
Sema.NominalTypeLookupDirectCount 35,218,830 35,171,223 -47,607 -0.14%
Sema.NumConstraintScopes 19,595,441 19,589,945 -5,496 -0.03%
Sema.NumConstraintsConsideredForEdgeContraction 51,983,630 51,981,895 -1,735 -0.0%
Sema.NumDeclsFinalized 1,993,114 1,992,163 -951 -0.05%
Sema.NumDeclsTypechecked 1,030,446 1,030,446 0 0.0%
Sema.NumDeclsValidated 2,384,967 2,384,933 -34 -0.0%
Sema.NumFunctionsTypechecked 936,038 935,892 -146 -0.02%
Sema.NumGenericSignatureBuilders 1,168,101 1,164,983 -3,118 -0.27%
Sema.NumLazyGenericEnvironments 10,429,527 10,386,016 -43,511 -0.42%
Sema.NumLazyGenericEnvironmentsLoaded 224,303 224,009 -294 -0.13%
Sema.NumLeafScopes 12,940,854 12,936,124 -4,730 -0.04%
Sema.NumTypesDeserialized 16,996,686 16,832,436 -164,250 -0.97%
Sema.NumTypesValidated 1,822,513 1,822,519 6 0.0%
Sema.OverriddenDeclsRequest 8,128,777 8,069,013 -59,764 -0.74%
Sema.PropertyDelegateBackingPropertyInfoRequest 273,414 273,374 -40 -0.01%
Sema.PropertyDelegateBackingPropertyTypeRequest 275,931 275,891 -40 -0.01%
Sema.PropertyDelegateTypeInfoRequest 0 0 0 0.0%
Sema.RequirementRequest 68,386 68,387 1 0.0%
Sema.RequirementSignatureRequest 70,361 70,023 -338 -0.48%
Sema.SetterAccessLevelRequest 157,927 157,927 0 0.0%
Sema.StructuralTypeRequest 0 0 0 0.0%
Sema.SuperclassDeclRequest 88,544 88,247 -297 -0.34%
Sema.SuperclassTypeRequest 38,463 38,463 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 33,066 33,056 -10 -0.03%

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,972,600,380,982 30,929,310,425,584 -43,289,955,398 -0.14%
LLVM.NumLLVMBytesOutput 989,198,658 989,201,386 2,728 0.0%
time.swift-driver.wall 5369.6s 5360.9s -8.7s -0.16%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (2)
name old new delta delta_pct
Sema.NumConformancesDeserialized 2,349,350 2,324,696 -24,654 -1.05% ✅
Sema.NumLazyIterableDeclContexts 805,534 775,352 -30,182 -3.75% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (20)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 229,964 229,819 -145 -0.06%
AST.NumLoadedModules 16,813 16,813 0 0.0%
AST.NumTotalClangImportedEntities 795,987 794,298 -1,689 -0.21%
IRModule.NumIRBasicBlocks 3,962,825 3,962,800 -25 -0.0%
IRModule.NumIRFunctions 1,781,846 1,781,851 5 0.0%
IRModule.NumIRGlobals 1,959,099 1,959,099 0 0.0%
IRModule.NumIRInsts 36,270,353 36,270,220 -133 -0.0%
IRModule.NumIRValueSymbols 3,472,554 3,472,559 5 0.0%
LLVM.NumLLVMBytesOutput 989,198,658 989,201,386 2,728 0.0%
SILModule.NumSILGenFunctions 758,388 758,383 -5 -0.0%
SILModule.NumSILOptFunctions 1,015,522 1,015,523 1 0.0%
Sema.NumConstraintScopes 17,760,906 17,760,896 -10 -0.0%
Sema.NumDeclsDeserialized 6,319,091 6,293,439 -25,652 -0.41%
Sema.NumDeclsValidated 1,208,647 1,208,647 0 0.0%
Sema.NumFunctionsTypechecked 361,889 361,840 -49 -0.01%
Sema.NumGenericSignatureBuilders 199,795 199,775 -20 -0.01%
Sema.NumLazyGenericEnvironments 1,296,773 1,296,176 -597 -0.05%
Sema.NumLazyGenericEnvironmentsLoaded 22,440 22,440 0 0.0%
Sema.NumTypesDeserialized 3,307,460 3,302,249 -5,211 -0.16%
Sema.NumTypesValidated 749,416 749,416 0 0.0%

Instead of visiting all types in the ExternalDefinitions list and
queuing up their conformances, just emit conformances as needed
when they are first referenced.
Just as with conformances, we can detect that a delayed function
needs to be added to the queue from 'first principles' rather than
walking the ExternalDefinitions list.

This completely eliminates the ExternalDefinitions walk from SILGen,
which has several advantages:

- It fixes a source of quadratic behavior. In batch mode, type checking
  produces a list of external definitions shared across all primary
  files. Then, SILGen runs once per primary file, building a delayed
  emission map every time.

- It allows SILGen to emit external definitions which only come into
  existence as a result of lazy conformance checking. Previously,
  anything that was added after SILGen performed its walk over the
  external definitions list would not be emitted.
This is just a stop-gap until getInterfaceType() becomes a request.
…Error conformers

Previously we would synthesize this in Sema, but this no longer
works when conformance checking is triggered by SILGen.
The walker in SILGenLazyConformance.cpp should be sufficient to catch
any conformances needed at runtime, and after all the recent changes
SILGen is now able to trigger lazy conformance checking and synthesis
of fully-checked function bodies for accessors, which is enough to
remove the explicit conformance checks from Sema in this case.
@slavapestov slavapestov force-pushed the lazy-nserror-bridging-conformances branch from a7f7711 to 73f1b10 Compare May 18, 2019 15:35
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit e6c31d1 into swiftlang:master May 19, 2019
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