Skip to content

[Serialization] Fast lookup of nested types in modules with overlays #20024

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 1 commit into from
Oct 25, 2018

Conversation

jrose-apple
Copy link
Contributor

Previously, the fast path for nested types only worked when the nested type was defined in a Swift module or a Clang module without an overlay; this is because it was originally designed to fix circularity issues when merging partial modules for a single target. By having a Swift overlay module pass through requests for nested types to the underlying Clang module, we get the fast-path behavior in more cases. (The one case where it won't kick in is if the overlay has a nested type that shadows a nested type from the Clang module, but that's probably pretty rare!)

Previously, the fast path for nested types only worked when the nested
type was defined in a Swift module or a Clang module without an
overlay; this is because it was originally designed to fix circularity
issues when merging partial modules for a single target. By having a
Swift overlay module pass through requests for nested types to the
underlying Clang module, we get the fast-path behavior in more cases.
(The one case where it /won't/ kick in is if the overlay has a nested
type that shadows a nested type from the Clang module, but that's
probably pretty rare!)
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test compiler performance

@jrose-apple
Copy link
Contributor Author

I did this hoping it would get past SR-9066, but no luck. It's still an improvement, though.

importedFromClang, /*isStatic*/false, /*ctorInit*/None,
singleValueBuffer);
if (!singleValueBuffer.empty()) {
values.assign({nestedType});
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, why assign a 1-element initializer list vs. calling push_back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A serialization cross-reference is a chain of nested names; when resolving component N, values contains the results from resolving component N-1.* So here we're saying we've resolved component N to a single result, and are replacing the results from component N-1.

* It's not always actually the immediately previous component; it's the previous component that represents a type. But, close enough.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3461769

@swift-ci
Copy link
Contributor

!!! Couldn't read commit file !!!

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test macOS

@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test compiler performance

@swift-ci
Copy link
Contributor

Build comment file:

Summary for master smoketest

Unexpected test results, excluded stats for Kingfisher, ReactiveCocoa, ReactiveSwift

No regressions above thresholds

Debug

debug 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 81,354,019,757 81,368,627,125 14,607,368 0.02%
LLVM.NumLLVMBytesOutput 3,125,472 3,125,472 0 0.0%
time.swift-driver.wall 10.9s 11.0s 57.0ms 0.52%

debug detailed

Regressed (0)
name old new delta delta_pct
Improved (1)
name old new delta delta_pct
AST.NumTotalClangImportedEntities 13,709 13,291 -418 -3.05% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (22)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 3,577 3,577 0 0.0%
AST.NumLoadedModules 654 654 0 0.0%
AST.NumUsedConformances 508 508 0 0.0%
IRModule.NumIRBasicBlocks 12,942 12,942 0 0.0%
IRModule.NumIRFunctions 5,750 5,750 0 0.0%
IRModule.NumIRGlobals 5,030 5,030 0 0.0%
IRModule.NumIRInsts 140,982 140,982 0 0.0%
IRModule.NumIRValueSymbols 10,407 10,407 0 0.0%
LLVM.NumLLVMBytesOutput 3,125,472 3,125,472 0 0.0%
SILModule.NumSILGenFunctions 2,673 2,673 0 0.0%
SILModule.NumSILOptFunctions 3,633 3,633 0 0.0%
Sema.NumConformancesDeserialized 8,953 8,951 -2 -0.02%
Sema.NumConstraintScopes 43,096 43,096 0 0.0%
Sema.NumDeclsDeserialized 98,483 98,450 -33 -0.03%
Sema.NumDeclsValidated 5,617 5,617 0 0.0%
Sema.NumFunctionsTypechecked 3,274 3,274 0 0.0%
Sema.NumGenericSignatureBuilders 2,735 2,730 -5 -0.18%
Sema.NumLazyGenericEnvironments 20,961 20,961 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 434 434 0 0.0%
Sema.NumLazyIterableDeclContexts 18,933 18,927 -6 -0.03%
Sema.NumTypesDeserialized 39,656 39,639 -17 -0.04%
Sema.NumTypesValidated 3,459 3,459 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 98,719,471,402 98,802,500,975 83,029,573 0.08%
LLVM.NumLLVMBytesOutput 3,258,884 3,258,876 -8 -0.0%
time.swift-driver.wall 18.5s 18.5s 47.4ms 0.26%

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) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 829 829 0 0.0%
AST.NumLoadedModules 65 65 0 0.0%
AST.NumTotalClangImportedEntities 3,127 3,127 0 0.0%
AST.NumUsedConformances 508 508 0 0.0%
IRModule.NumIRBasicBlocks 14,026 14,026 0 0.0%
IRModule.NumIRFunctions 4,723 4,723 0 0.0%
IRModule.NumIRGlobals 4,577 4,577 0 0.0%
IRModule.NumIRInsts 119,825 119,825 0 0.0%
IRModule.NumIRValueSymbols 9,080 9,080 0 0.0%
LLVM.NumLLVMBytesOutput 3,258,884 3,258,876 -8 -0.0%
SILModule.NumSILGenFunctions 2,124 2,124 0 0.0%
SILModule.NumSILOptFunctions 3,019 3,019 0 0.0%
Sema.NumConformancesDeserialized 5,917 5,917 0 0.0%
Sema.NumConstraintScopes 37,838 37,838 0 0.0%
Sema.NumDeclsDeserialized 22,509 22,509 0 0.0%
Sema.NumDeclsValidated 3,000 3,000 0 0.0%
Sema.NumFunctionsTypechecked 1,676 1,676 0 0.0%
Sema.NumGenericSignatureBuilders 633 633 0 0.0%
Sema.NumLazyGenericEnvironments 4,684 4,684 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 85 85 0 0.0%
Sema.NumLazyIterableDeclContexts 3,223 3,223 0 0.0%
Sema.NumTypesDeserialized 12,203 12,203 0 0.0%
Sema.NumTypesValidated 1,517 1,517 0 0.0%

@jrose-apple jrose-apple merged commit 14d4235 into swiftlang:master Oct 25, 2018
@jrose-apple jrose-apple deleted the from-shadows branch October 25, 2018 01:56
davidungar pushed a commit to davidungar/swift that referenced this pull request Oct 26, 2018
…wiftlang#20024)

Previously, the fast path for nested types only worked when the nested
type was defined in a Swift module or a Clang module without an
overlay; this is because it was originally designed to fix circularity
issues when merging partial modules for a single target. By having a
Swift overlay module pass through requests for nested types to the
underlying Clang module, we get the fast-path behavior in more cases.
(The one case where it /won't/ kick in is if the overlay has a nested
type that shadows a nested type from the Clang module, but that's
probably pretty rare!)
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