Skip to content
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

[5.1] One-way constraints for function builders #26661

Merged

Conversation

DougGregor
Copy link
Member

Cherry-pick the work to enable one-way constraints for function builders to the 5.1 branch as an experiment. Implements rdar://problem/50150793.

gmittert and others added 23 commits August 14, 2019 18:10
The ConstraintSystem class is on the order of 1000s of bytes in size on
the stacka nd is causing issues with dispatch's 64k stack limit.

This changes most Small data types which store data on the stack to non
small heap based data types.
The constraint graph maintains a fairly heavyweight list of
adjacencies that is only used in two operations: connected components
and gathering related constraints. Switch connected components over to
primarily use the set of constraints (which are necessary for many
reasons), reducing the need for the adjacencies list.

(cherry picked from commit 6a970a8)
…adjacencies list.

Use the adjacencies implied by the constraints of a node rather than looking
at the "adjacency" list, and try to simplify this code path a bit. The
diagnostic change is because we are now uniformly recording the
members of the equivalence class.

(cherry picked from commit 54bdd7b)
Each constraint graph node maintained adjacency information that was
fairly expensive---a vector of type variables and a dense map of extra
adjacency information---and that was continuously maintained. Remove
this adjacency information, instead recomputing it by walking the
constraints (to get their type variables) and having a separate
(smaller) list of type variables that are adjacent due to fixed
bindings. This simplifies the constraint graph code and reduces
per-node memory overhead.

(cherry picked from commit dfdd352)
Simplify the interface to gatherConstraints() by performing the
uniquing within the function itself and returning only the resulting
(uniqued) vector of constraints.

(cherry picked from commit 8355f3d)
…riables.

The API of the connected-components algorithm asks clients to
provide the set of type variables of interest. However, the connected
components algorithm itself was operating across the entire set of
type variables, then narrowing the result down to the type variables
of interest. Instead, only perform connected components on those type
variables of interest, so that we are only doing work proportional to
the subgraph we're working in.

(cherry picked from commit 62502ef)
Address a silly mistake that meant we were miscomputing connected
components.

(cherry picked from commit 6be6401)
…iables.

Simplify the connected-components computation slightly and make sure
that it never performs work outside of the subgraph described by the
input set of type variables.

(cherry picked from commit 14ca9d1)
…ere.

When we are associating type variables with components in a “split” step,
there is no need to record already-bound type variables with every component.

(cherry picked from commit 0b61f86)
The connected components computation was not forming components when all of
the type variables in a component were already bound. Any remaining
constraints involving those type variables would then arbitrarily end up
in component 0, due to the the default-construction behavior of a map’s
operator[] with missing keys, artificially increasing the size of that
component with (typically) additional disjunctions.

Ensure that all constraints get into a component, creating one to hold
the a constraint even when all of the type variables are already bound.
Then, assert the invariant that every constraint is associated with a
component.

In time, we should probably eliminate this notion of disjunctions that
remain even when the type variable has been bound. For now, strengthen the
invariant to at least ensure that they get solved in isolation.

(cherry picked from commit 805b02d)
Have the constraint graph's connected-component implementation be more
self-contained, producing a vector containing each of the actual
components (where each is defined by a list of type variables and a list
of constraints). This simplifies the contract with the client
(SplitterStep) and eliminates a bunch of separate mapping steps to
interpret the results.

It also lets us enrich the Component data structure in the future.

(cherry picked from commit 4c04ced)
Maintain the order of constraints when splitting the system into
connected components, to match the behavior prior to the refactoring
into a separate connected-components algorithm.

(cherry picked from commit 5a4af23)
…nents

Move the logic for creating connected components of orphaned
constraints into the connected-components algorithm code, rather than
making it a special part of SplitterStep.

(cherry picked from commit ab38be1)
Introduce the notion of "one-way" binding constraints of the form

  $T0 one-way bind to $T1

which treats the type variables $T0 and $T1 as independent up until
the point where $T1 simplifies down to a concrete type, at which point
$T0 will be bound to that concrete type. $T0 won't be bound in any
other way, so type information ends up being propagated right-to-left,
only. This allows a constraint system to be broken up in more
components that are solved independently. Specifically, the connected
components algorithm now proceeds as follows:

1. Compute connected components, excluding one-way constraints from
consideration.
2. Compute a directed graph amongst the components using only the
one-way constraints, where an edge A -> B indicates that the type
variables in component A need to be solved before those in component
B.
3. Using the directed graph, compute the set of components that need
to be solved before a given component.

To utilize this, implement a new kind of solver step that handles the
propagation of partial solutions across one-way constraints. This
introduces a new kind of "split" within a connected component, where
we collect each combination of partial solutions for the input
components and (separately) try to solve the constraints in this
component. Any correct solution from any of these attempts will then
be recorded as a (partial) solution for this component.

For example, consider:

  let _: Int8 = b ? Builtin.one_way(int8Or16(17)) :
  Builtin.one_way(int8Or16(42\
))

where int8Or16 is overloaded with types `(Int8) -> Int8` and
`(Int16) -> Int16`. There are two one-way components (`int8Or16(17)`)
and (`int8Or16(42)`), each of which can produce a value of type `Int8`
or `Int16`. Those two components will be solved independently, and the
partial solutions for each will be fed into the component that
evaluates the ternary operator. There are four ways to attempt that
evaluation:

```
  [Int8, Int8]
  [Int8, Int16]
  [Int16, Int8]
  [Int16, Int16]

To test this, introduce a new expression builtin `Builtin.one_way(x)` that
introduces a one-way expression constraint binding the result of the
expression 'x'. The builtin is meant to be used for testing purposes,
and the one-way constraint expression itself can be synthesized by the
type checker to introduce one-way constraints later on.

Of these two, there are only two (partial) solutions that can work at
all, because the types in the ternary operator need a common
supertype:

  [Int8, Int8]
  [Int16, Int16]

Therefore, these are the partial solutions that will be considered the
results of the component containing the ternary expression. Note that
only one of them meets the final constraint (convertibility to
`Int8`), so the expression is well-formed.

Part of rdar://problem/50150793.

(cherry picked from commit 3c69f6a)
…ilders

When we transform each expression or statement in a function builder,
introduce a one-way constraint so that type information does not flow
backwards from the context into that statement or expression. This
more closely mimics the behavior of normal code, where type inference
is per-statement, flowing from top to bottom.

This also allows us to isolate different expressions and statements
within a closure that's passed into a function builder parameter,
reducing the search space and (hopefully) improving compile times for
large function builder closures.

For now, put this functionality behind the compiler flag
`-enable-function-builder-one-way-constraints` for testing purposes;
we still have both optimization and correctness work to do to turn
this on by default.

(cherry picked from commit be73a9d)
…er calls

We need both sides of a buildEither constraint to be unified, so don’t
inject one-way constraints on the inputs to buildEither.

(cherry picked from commit 7aecca0)
…ponents.

Helps with debugging the constraint graph.

(cherry picked from commit 0b7ef34)
Refactoring so we can use this in a moment.

(cherry picked from commit f19016b)
When we encounter a cycle in the one-way component graph due to constraints
that (e.g.) tie together the outputs of two one-way constraints, collapse
the components along the cycle into a single connected component, because
all of those type variables must be solved together.

(cherry picked from commit 73e5a64)
@DougGregor DougGregor requested a review from a team as a code owner August 15, 2019 01:15
We only care about gathering a one-way constraint if (1) the left-hand
side is in the set of type variables we care about now, and (2) the
type variable we started from is in the right-hand side.
There were a few places where we wanted fast testing to see whether a
particular type variable is currently of interest. Instead of building
local hash tables in those places, keep type variables in a SetVector
for efficient testing.
One-way constraint expressions, which are the only things that
introduce one-way constraints at this point, want to look through
lvalue types to produce values. Rename OneWayBind to OneWayEqual, map
it down to an Equal constraint when it is simplified (to drop
lvalue-ness), and apply that coercion during constraint application.

Part of rdar://problem/50150793.
Enable one-way constraints by default for function builders, finishing
rdar://problem/50150793.

(cherry picked from commit b4e80cf)
Function builders perform the expression "pre-check" operation
multiple times, which means that nested closures might have a
more-nested DeclContext than PreCheck expects. Loosen this assertion
to cope with that change.

(cherry picked from commit 79c5706)
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - af01c08

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - af01c08

@swift-ci
Copy link
Contributor

Summary for swift-5.1-branch full

Unexpected test results, excluded stats for SwifterSwift

No regressions above thresholds

Debug-batch

debug-batch brief

Regressed (0)
name old new delta delta_pct
Improved (1)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 46,318,740,902,914 45,621,680,708,588 -697,060,194,326 -1.5% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (2)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 1,824,194,244 1,824,187,540 -6,704 -0.0%
time.swift-driver.wall 5084.0s 5050.9s -33.1s -0.65%

debug-batch detailed

Regressed (0)
name old new delta delta_pct
Improved (13)
name old new delta delta_pct
AST.NumASTBytesAllocated 70,959,549,898 69,630,750,860 -1,328,799,038 -1.87% ✅
Driver.ChildrenMaxRSS 237,739,538,432 234,342,320,128 -3,397,218,304 -1.43% ✅
Frontend.NumInstructionsExecuted 46,318,740,902,914 45,621,680,708,588 -697,060,194,326 -1.5% ✅
Sema.AccessLevelRequest 12,687,437 12,216,626 -470,811 -3.71% ✅
Sema.DefaultTypeRequest 605,851 564,764 -41,087 -6.78% ✅
Sema.NumConformancesDeserialized 10,400,802 10,234,228 -166,574 -1.6% ✅
Sema.NumConstraintScopes 29,272,479 28,192,715 -1,079,764 -3.69% ✅
Sema.NumConstraintsConsideredForEdgeContraction 79,511,688 76,541,153 -2,970,535 -3.74% ✅
Sema.NumDeclsDeserialized 78,828,091 77,653,943 -1,174,148 -1.49% ✅
Sema.NumLazyGenericEnvironments 14,600,706 14,341,800 -258,906 -1.77% ✅
Sema.NumLeafScopes 19,350,644 18,738,152 -612,492 -3.17% ✅
Sema.OverriddenDeclsRequest 3,987,747 3,945,515 -42,232 -1.06% ✅
Sema.USRGenerationRequest 8,169,921 7,880,208 -289,713 -3.55% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (97)
name old new delta delta_pct
AST.NumDecls 145,966 145,966 0 0.0%
AST.NumDependencies 331,017 331,029 12 0.0%
AST.NumImportedExternalDefinitions 1,902,376 1,902,376 0 0.0%
AST.NumInfixOperators 54,471 54,471 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 409,198 409,198 0 0.0%
AST.NumLocalTypeDecls 253 253 0 0.0%
AST.NumObjCMethods 25,152 25,152 0 0.0%
AST.NumPostfixOperators 23 23 0 0.0%
AST.NumPrecedenceGroups 26,374 26,374 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 211 211 0 0.0%
AST.NumReferencedMemberNames 6,441,601 6,441,637 36 0.0%
AST.NumReferencedTopLevelNames 493,346 493,346 0 0.0%
AST.NumSourceBuffers 594,510 594,510 0 0.0%
AST.NumSourceLines 4,796,707 4,796,707 0 0.0%
AST.NumSourceLinesPerSecond 3,599,356 3,624,877 25,521 0.71%
AST.NumStoredPropertiesQueries 14,682,974 14,682,722 -252 -0.0%
AST.NumTotalClangImportedEntities 7,134,305 7,122,350 -11,955 -0.17%
AST.NumUsedConformances 417,026 417,026 0 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 29,106 29,106 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumDriverPipePolls 89,952 89,114 -838 -0.93%
Driver.NumDriverPipeReads 84,395 83,966 -429 -0.51%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 1,324,931,947,168 1,315,149,074,744 -9,782,872,424 -0.74%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 200,465 200,465 0 0.0%
IRModule.NumIRBasicBlocks 7,056,314 7,056,314 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,437,927 3,437,927 0 0.0%
IRModule.NumIRGlobals 3,472,114 3,472,114 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 89,232,918 89,232,917 -1 -0.0%
IRModule.NumIRNamedMetaData 140,170 140,170 0 0.0%
IRModule.NumIRValueSymbols 6,250,047 6,250,047 0 0.0%
LLVM.NumLLVMBytesOutput 1,824,194,244 1,824,187,540 -6,704 -0.0%
Parse.NumFunctionsParsed 273,434 273,434 0 0.0%
Parse.NumIterableDeclContextParsed 1,911,819 1,911,819 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,751,047 1,751,048 1 0.0%
SILModule.NumSILGenGlobalVariables 54,454 54,454 0 0.0%
SILModule.NumSILGenVtables 18,945 18,945 0 0.0%
SILModule.NumSILGenWitnessTables 74,208 74,208 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,459,221 2,459,221 0 0.0%
SILModule.NumSILOptGlobalVariables 56,077 56,077 0 0.0%
SILModule.NumSILOptVtables 31,974 31,974 0 0.0%
SILModule.NumSILOptWitnessTables 161,585 161,585 0 0.0%
Sema.AttachedFunctionBuilderRequest 15 15 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 475,348 475,348 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,425,155 2,425,155 0 0.0%
Sema.CustomAttrNominalRequest 17 17 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 106,694 106,678 -16 -0.01%
Sema.EnumRawTypeRequest 33,605 33,605 0 0.0%
Sema.ExtendedNominalRequest 6,459,689 6,422,812 -36,877 -0.57%
Sema.FunctionBuilderTypeRequest 15 15 0 0.0%
Sema.InheritedDeclsReferencedRequest 8,210,471 8,182,508 -27,963 -0.34%
Sema.InheritedTypeRequest 714,342 714,400 58 0.01%
Sema.IsDynamicRequest 3,536,454 3,536,454 0 0.0%
Sema.IsObjCRequest 3,059,784 3,055,030 -4,754 -0.16%
Sema.MangleLocalTypeDeclRequest 506 506 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 37,647 37,727 80 0.21%
Sema.NamedLazyMemberLoadSuccessCount 31,307,695 31,198,385 -109,310 -0.35%
Sema.NominalTypeLookupDirectCount 53,885,581 53,677,427 -208,154 -0.39%
Sema.NumDeclsFinalized 3,192,501 3,192,501 0 0.0%
Sema.NumDeclsTypechecked 1,614,320 1,614,320 0 0.0%
Sema.NumDeclsValidated 3,877,087 3,877,071 -16 -0.0%
Sema.NumFunctionsTypechecked 1,683,540 1,683,540 0 0.0%
Sema.NumGenericSignatureBuilders 2,082,030 2,069,874 -12,156 -0.58%
Sema.NumLazyGenericEnvironmentsLoaded 338,717 338,592 -125 -0.04%
Sema.NumLazyIterableDeclContexts 11,151,809 11,106,978 -44,831 -0.4%
Sema.NumLazyRequirementSignatures 1,092,412 1,090,364 -2,048 -0.19%
Sema.NumLazyRequirementSignaturesLoaded 737,961 736,424 -1,537 -0.21%
Sema.NumTypesDeserialized 24,702,178 24,467,140 -235,038 -0.95%
Sema.NumTypesValidated 2,898,265 2,898,245 -20 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 7,422,194 7,457,537 35,343 0.48%
Sema.PropertyWrapperBackingPropertyInfoRequest 469,866 469,866 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 475,348 475,348 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 5 5 0 0.0%
Sema.RequirementRequest 132,891 132,888 -3 -0.0%
Sema.SelfBoundsFromWhereClauseRequest 11,191,088 11,138,508 -52,580 -0.47%
Sema.SetterAccessLevelRequest 259,690 259,690 0 0.0%
Sema.SuperclassDeclRequest 541,964 540,426 -1,538 -0.28%
Sema.SuperclassTypeRequest 66,359 66,362 3 0.0%
Sema.TypeDeclsFromWhereClauseRequest 56,790 56,774 -16 -0.03%
Sema.UnderlyingTypeDeclsReferencedRequest 407,697 406,702 -995 -0.24%

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 47,924,164,532,790 47,694,041,020,353 -230,123,512,437 -0.48%
LLVM.NumLLVMBytesOutput 1,597,810,918 1,597,808,662 -2,256 -0.0%
time.swift-driver.wall 8485.5s 8454.8s -30.7s -0.36%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (4)
name old new delta delta_pct
Sema.DefaultTypeRequest 574,109 532,760 -41,349 -7.2% ✅
Sema.NumConstraintScopes 26,512,993 25,453,908 -1,059,085 -3.99% ✅
Sema.NumConstraintsConsideredForEdgeContraction 78,785,764 75,798,150 -2,987,614 -3.79% ✅
Sema.NumLeafScopes 17,124,341 16,530,451 -593,890 -3.47% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (106)
name old new delta delta_pct
AST.NumASTBytesAllocated 9,903,673,013 9,903,758,609 85,596 0.0%
AST.NumDecls 146,696 146,696 0 0.0%
AST.NumDependencies 25,916 25,912 -4 -0.02%
AST.NumImportedExternalDefinitions 378,677 378,677 0 0.0%
AST.NumInfixOperators 54,867 54,867 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 30,739 30,739 0 0.0%
AST.NumLocalTypeDecls 253 253 0 0.0%
AST.NumObjCMethods 25,631 25,631 0 0.0%
AST.NumPostfixOperators 23 23 0 0.0%
AST.NumPrecedenceGroups 26,466 26,466 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 0 0 0 0.0%
AST.NumReferencedMemberNames 1,468 1,468 0 0.0%
AST.NumReferencedTopLevelNames 118 118 0 0.0%
AST.NumSourceBuffers 28,273 28,273 0 0.0%
AST.NumSourceLines 4,833,234 4,833,234 0 0.0%
AST.NumSourceLinesPerSecond 375,086 375,831 745 0.2%
AST.NumStoredPropertiesQueries 88,342,101 88,342,517 416 0.0%
AST.NumTotalClangImportedEntities 1,285,513 1,285,513 0 0.0%
AST.NumUsedConformances 420,104 420,104 0 0.0%
Driver.ChildrenMaxRSS 311,942,940,672 312,013,883,392 70,942,720 0.02%
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 1,316 1,316 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumDriverPipePolls 46,546 46,268 -278 -0.6%
Driver.NumDriverPipeReads 45,230 44,954 -276 -0.61%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 265,013,933,864 265,192,438,304 178,504,440 0.07%
Frontend.NumInstructionsExecuted 47,924,164,532,790 47,694,041,020,353 -230,123,512,437 -0.48%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 160,242 160,242 0 0.0%
IRModule.NumIRBasicBlocks 6,395,518 6,395,521 3 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 2,907,865 2,907,865 0 0.0%
IRModule.NumIRGlobals 3,055,864 3,055,864 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 57,911,543 57,911,559 16 0.0%
IRModule.NumIRNamedMetaData 131,395 131,395 0 0.0%
IRModule.NumIRValueSymbols 5,587,945 5,587,945 0 0.0%
LLVM.NumLLVMBytesOutput 1,597,810,918 1,597,808,662 -2,256 -0.0%
Parse.NumFunctionsParsed 275,236 275,236 0 0.0%
Parse.NumIterableDeclContextParsed 92,951 92,951 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,214,998 1,214,999 1 0.0%
SILModule.NumSILGenGlobalVariables 54,093 54,093 0 0.0%
SILModule.NumSILGenVtables 19,012 19,012 0 0.0%
SILModule.NumSILGenWitnessTables 69,666 69,666 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 1,616,483 1,616,483 0 0.0%
SILModule.NumSILOptGlobalVariables 51,544 51,544 0 0.0%
SILModule.NumSILOptVtables 21,881 21,881 0 0.0%
SILModule.NumSILOptWitnessTables 118,889 118,889 0 0.0%
Sema.AccessLevelRequest 1,581,233 1,581,233 0 0.0%
Sema.AttachedFunctionBuilderRequest 13 13 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 180,000 180,000 0 0.0%
Sema.AttachedPropertyWrappersRequest 1,547,209 1,547,209 0 0.0%
Sema.CustomAttrNominalRequest 13 13 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 40,408 40,408 0 0.0%
Sema.EnumRawTypeRequest 8,910 8,910 0 0.0%
Sema.ExtendedNominalRequest 831,943 831,934 -9 -0.0%
Sema.FunctionBuilderTypeRequest 13 13 0 0.0%
Sema.InheritedDeclsReferencedRequest 1,294,751 1,295,159 408 0.03%
Sema.InheritedTypeRequest 186,510 186,510 0 0.0%
Sema.IsDynamicRequest 1,285,811 1,285,811 0 0.0%
Sema.IsObjCRequest 1,115,007 1,115,007 0 0.0%
Sema.MangleLocalTypeDeclRequest 263 263 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 9,213 9,213 0 0.0%
Sema.NamedLazyMemberLoadSuccessCount 15,414,670 15,300,643 -114,027 -0.74%
Sema.NominalTypeLookupDirectCount 33,662,530 33,611,293 -51,237 -0.15%
Sema.NumConformancesDeserialized 3,807,001 3,806,979 -22 -0.0%
Sema.NumDeclsDeserialized 10,649,490 10,649,475 -15 -0.0%
Sema.NumDeclsFinalized 1,197,598 1,197,598 0 0.0%
Sema.NumDeclsTypechecked 1,637,505 1,637,505 0 0.0%
Sema.NumDeclsValidated 1,965,177 1,965,177 0 0.0%
Sema.NumFunctionsTypechecked 776,430 776,430 0 0.0%
Sema.NumGenericSignatureBuilders 366,948 366,947 -1 -0.0%
Sema.NumLazyGenericEnvironments 2,112,942 2,112,942 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 36,191 36,191 0 0.0%
Sema.NumLazyIterableDeclContexts 1,403,712 1,403,699 -13 -0.0%
Sema.NumLazyRequirementSignatures 114,696 114,695 -1 -0.0%
Sema.NumLazyRequirementSignaturesLoaded 89,302 89,302 0 0.0%
Sema.NumTypesDeserialized 5,460,887 5,460,885 -2 -0.0%
Sema.NumTypesValidated 1,159,214 1,159,214 0 0.0%
Sema.NumUnloadedLazyIterableDeclContexts 866,155 866,142 -13 -0.0%
Sema.OverriddenDeclsRequest 1,098,520 1,098,520 0 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 176,745 176,745 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 180,000 180,000 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 4 4 0 0.0%
Sema.RequirementRequest 77,441 77,441 0 0.0%
Sema.SelfBoundsFromWhereClauseRequest 1,811,932 1,812,260 328 0.02%
Sema.SetterAccessLevelRequest 130,484 130,484 0 0.0%
Sema.SuperclassDeclRequest 101,395 101,395 0 0.0%
Sema.SuperclassTypeRequest 25,551 25,551 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 23,183 23,183 0 0.0%
Sema.USRGenerationRequest 169,546 169,546 0 0.0%
Sema.UnderlyingTypeDeclsReferencedRequest 67,351 67,351 0 0.0%

@DougGregor
Copy link
Member Author

@swift-ci please test

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please test

Reinstate the list of adjacencies in each constraint graph node,
effectively reverting
dfdd352. Exclude one-way constraints
from this computation; we'll handle them separately.
This reinstates the use of direct adjacency information when gathering
constraints, effectively reverting
54bdd7b.
Fixes the regression that commit caused, which is tracked by
rdar://problem/54274245.
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test compiler performance

@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please test compiler performance

@DougGregor DougGregor changed the title [Do Not Merge][5.1] One-way constraints for function builders [5.1] One-way constraints for function builders Aug 22, 2019
@swift-ci
Copy link
Contributor

Summary for swift-5.1-branch full

Unexpected test results, excluded stats for SwifterSwift, Base64CoderSwiftUI

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 46,321,788,742,667 45,989,823,206,049 -331,965,536,618 -0.72%
LLVM.NumLLVMBytesOutput 1,823,680,294 1,823,682,046 1,752 0.0%
time.swift-driver.wall 5074.0s 5089.1s 15.1s 0.3%

debug-batch detailed

Regressed (3)
name old new delta delta_pct
Sema.NumConstraintScopes 29,273,956 30,503,376 1,229,420 4.2% ⛔
Sema.NumConstraintsConsideredForEdgeContraction 79,511,722 88,575,616 9,063,894 11.4% ⛔
Sema.NumLeafScopes 19,351,926 20,132,802 780,876 4.04% ⛔
Improved (3)
name old new delta delta_pct
Sema.AccessLevelRequest 12,755,018 12,537,294 -217,724 -1.71% ✅
Sema.DefaultTypeRequest 605,800 564,735 -41,065 -6.78% ✅
Sema.USRGenerationRequest 8,256,870 8,091,518 -165,352 -2.0% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (104)
name old new delta delta_pct
AST.NumASTBytesAllocated 71,078,128,430 70,488,065,519 -590,062,911 -0.83%
AST.NumDecls 145,938 145,938 0 0.0%
AST.NumDependencies 331,036 331,044 8 0.0%
AST.NumImportedExternalDefinitions 1,901,400 1,901,400 0 0.0%
AST.NumInfixOperators 54,468 54,468 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 409,013 409,013 0 0.0%
AST.NumLocalTypeDecls 253 253 0 0.0%
AST.NumObjCMethods 25,138 25,138 0 0.0%
AST.NumPostfixOperators 23 23 0 0.0%
AST.NumPrecedenceGroups 26,369 26,369 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 211 211 0 0.0%
AST.NumReferencedMemberNames 6,440,327 6,440,293 -34 -0.0%
AST.NumReferencedTopLevelNames 493,274 493,274 0 0.0%
AST.NumSourceBuffers 594,494 594,494 0 0.0%
AST.NumSourceLines 4,796,290 4,796,290 0 0.0%
AST.NumSourceLinesPerSecond 3,616,242 3,631,687 15,445 0.43%
AST.NumStoredPropertiesQueries 14,678,910 14,678,714 -196 -0.0%
AST.NumTotalClangImportedEntities 7,146,936 7,129,973 -16,963 -0.24%
AST.NumUsedConformances 416,944 416,944 0 0.0%
Driver.ChildrenMaxRSS 237,085,335,552 234,819,010,560 -2,266,324,992 -0.96%
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,101 29,101 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumDriverPipePolls 89,147 88,380 -767 -0.86%
Driver.NumDriverPipeReads 83,852 83,184 -668 -0.8%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 1,326,698,125,688 1,320,124,084,760 -6,574,040,928 -0.5%
Frontend.NumInstructionsExecuted 46,321,788,742,667 45,989,823,206,049 -331,965,536,618 -0.72%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 200,381 200,381 0 0.0%
IRModule.NumIRBasicBlocks 7,054,875 7,054,875 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 3,436,924 3,436,924 0 0.0%
IRModule.NumIRGlobals 3,470,917 3,470,917 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 89,217,151 89,217,151 0 0.0%
IRModule.NumIRNamedMetaData 140,150 140,150 0 0.0%
IRModule.NumIRValueSymbols 6,247,977 6,247,977 0 0.0%
LLVM.NumLLVMBytesOutput 1,823,680,294 1,823,682,046 1,752 0.0%
Parse.NumFunctionsParsed 273,398 273,398 0 0.0%
Parse.NumIterableDeclContextParsed 1,911,719 1,911,719 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,750,581 1,750,581 0 0.0%
SILModule.NumSILGenGlobalVariables 54,454 54,454 0 0.0%
SILModule.NumSILGenVtables 18,939 18,939 0 0.0%
SILModule.NumSILGenWitnessTables 74,169 74,169 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 2,458,529 2,458,529 0 0.0%
SILModule.NumSILOptGlobalVariables 56,076 56,076 0 0.0%
SILModule.NumSILOptVtables 31,962 31,962 0 0.0%
SILModule.NumSILOptWitnessTables 161,505 161,505 0 0.0%
Sema.AttachedFunctionBuilderRequest 3 3 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 475,209 475,209 0 0.0%
Sema.AttachedPropertyWrappersRequest 2,424,337 2,424,337 0 0.0%
Sema.CustomAttrNominalRequest 3 3 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 106,666 106,671 5 0.0%
Sema.EnumRawTypeRequest 33,603 33,603 0 0.0%
Sema.ExtendedNominalRequest 6,466,891 6,444,534 -22,357 -0.35%
Sema.FunctionBuilderTypeRequest 3 3 0 0.0%
Sema.InheritedDeclsReferencedRequest 8,235,986 8,204,924 -31,062 -0.38%
Sema.InheritedTypeRequest 714,581 714,602 21 0.0%
Sema.IsDynamicRequest 3,535,827 3,535,827 0 0.0%
Sema.IsObjCRequest 3,059,786 3,057,068 -2,718 -0.09%
Sema.MangleLocalTypeDeclRequest 506 506 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 37,722 37,683 -39 -0.1%
Sema.NamedLazyMemberLoadSuccessCount 31,303,650 31,235,035 -68,615 -0.22%
Sema.NominalTypeLookupDirectCount 53,916,087 53,794,473 -121,614 -0.23%
Sema.NumConformancesDeserialized 10,431,379 10,348,088 -83,291 -0.8%
Sema.NumDeclsDeserialized 79,093,619 78,471,614 -622,005 -0.79%
Sema.NumDeclsFinalized 3,191,968 3,191,968 0 0.0%
Sema.NumDeclsTypechecked 1,613,901 1,613,901 0 0.0%
Sema.NumDeclsValidated 3,876,678 3,876,685 7 0.0%
Sema.NumFunctionsTypechecked 1,682,751 1,682,751 0 0.0%
Sema.NumGenericSignatureBuilders 2,083,859 2,076,931 -6,928 -0.33%
Sema.NumLazyGenericEnvironments 14,615,933 14,502,506 -113,427 -0.78%
Sema.NumLazyGenericEnvironmentsLoaded 338,753 338,727 -26 -0.01%
Sema.NumLazyIterableDeclContexts 11,160,928 11,131,406 -29,522 -0.26%
Sema.NumLazyRequirementSignatures 1,092,172 1,091,077 -1,095 -0.1%
Sema.NumLazyRequirementSignaturesLoaded 738,056 737,121 -935 -0.13%
Sema.NumTypesDeserialized 24,739,932 24,619,060 -120,872 -0.49%
Sema.NumTypesValidated 2,898,083 2,898,104 21 0.0%
Sema.NumUnloadedLazyIterableDeclContexts 7,420,142 7,429,669 9,527 0.13%
Sema.OverriddenDeclsRequest 3,995,798 3,974,613 -21,185 -0.53%
Sema.PropertyWrapperBackingPropertyInfoRequest 469,733 469,733 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 475,209 475,209 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 1 1 0 0.0%
Sema.RequirementRequest 132,885 132,894 9 0.01%
Sema.SelfBoundsFromWhereClauseRequest 11,224,454 11,178,702 -45,752 -0.41%
Sema.SetterAccessLevelRequest 259,655 259,655 0 0.0%
Sema.SuperclassDeclRequest 542,326 541,480 -846 -0.16%
Sema.SuperclassTypeRequest 66,344 66,347 3 0.0%
Sema.TypeDeclsFromWhereClauseRequest 56,771 56,776 5 0.01%
Sema.UnderlyingTypeDeclsReferencedRequest 408,659 407,450 -1,209 -0.3%

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 47,915,183,374,249 47,853,633,918,163 -61,549,456,086 -0.13%
LLVM.NumLLVMBytesOutput 1,597,444,946 1,597,442,750 -2,196 -0.0%
time.swift-driver.wall 8477.5s 8494.1s 16.7s 0.2%

release detailed

Regressed (3)
name old new delta delta_pct
Sema.NumConstraintScopes 26,511,026 27,747,719 1,236,693 4.66% ⛔
Sema.NumConstraintsConsideredForEdgeContraction 78,784,321 87,831,688 9,047,367 11.48% ⛔
Sema.NumLeafScopes 17,122,865 17,909,815 786,950 4.6% ⛔
Improved (1)
name old new delta delta_pct
Sema.DefaultTypeRequest 574,062 532,735 -41,327 -7.2% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (106)
name old new delta delta_pct
AST.NumASTBytesAllocated 9,894,435,142 9,894,361,522 -73,620 -0.0%
AST.NumDecls 146,669 146,669 0 0.0%
AST.NumDependencies 25,888 25,886 -2 -0.01%
AST.NumImportedExternalDefinitions 377,936 377,936 0 0.0%
AST.NumInfixOperators 54,864 54,864 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 30,703 30,703 0 0.0%
AST.NumLocalTypeDecls 253 253 0 0.0%
AST.NumObjCMethods 25,617 25,617 0 0.0%
AST.NumPostfixOperators 23 23 0 0.0%
AST.NumPrecedenceGroups 26,461 26,461 0 0.0%
AST.NumPrefixOperators 99 99 0 0.0%
AST.NumReferencedDynamicNames 0 0 0 0.0%
AST.NumReferencedMemberNames 1,468 1,468 0 0.0%
AST.NumReferencedTopLevelNames 118 118 0 0.0%
AST.NumSourceBuffers 28,269 28,269 0 0.0%
AST.NumSourceLines 4,832,817 4,832,817 0 0.0%
AST.NumSourceLinesPerSecond 375,699 375,735 36 0.01%
AST.NumStoredPropertiesQueries 88,322,868 88,324,711 1,843 0.0%
AST.NumTotalClangImportedEntities 1,283,330 1,283,330 0 0.0%
AST.NumUsedConformances 420,024 420,024 0 0.0%
Driver.ChildrenMaxRSS 311,190,986,752 311,662,170,112 471,183,360 0.15%
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 1,315 1,315 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumDriverPipePolls 45,973 46,169 196 0.43%
Driver.NumDriverPipeReads 44,658 44,857 199 0.45%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 264,121,928,544 264,769,680,808 647,752,264 0.25%
Frontend.NumInstructionsExecuted 47,915,183,374,249 47,853,633,918,163 -61,549,456,086 -0.13%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 160,181 160,181 0 0.0%
IRModule.NumIRBasicBlocks 6,394,523 6,394,523 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 2,907,285 2,907,285 0 0.0%
IRModule.NumIRGlobals 3,054,928 3,054,928 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 57,903,833 57,903,833 0 0.0%
IRModule.NumIRNamedMetaData 131,375 131,375 0 0.0%
IRModule.NumIRValueSymbols 5,586,540 5,586,540 0 0.0%
LLVM.NumLLVMBytesOutput 1,597,444,946 1,597,442,750 -2,196 -0.0%
Parse.NumFunctionsParsed 275,200 275,200 0 0.0%
Parse.NumIterableDeclContextParsed 92,926 92,926 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,214,616 1,214,616 0 0.0%
SILModule.NumSILGenGlobalVariables 54,093 54,093 0 0.0%
SILModule.NumSILGenVtables 19,006 19,006 0 0.0%
SILModule.NumSILGenWitnessTables 69,629 69,629 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 1,616,122 1,616,122 0 0.0%
SILModule.NumSILOptGlobalVariables 51,543 51,543 0 0.0%
SILModule.NumSILOptVtables 21,874 21,874 0 0.0%
SILModule.NumSILOptWitnessTables 118,838 118,838 0 0.0%
Sema.AccessLevelRequest 1,580,951 1,580,951 0 0.0%
Sema.AttachedFunctionBuilderRequest 1 1 0 0.0%
Sema.AttachedPropertyWrapperTypeRequest 179,914 179,914 0 0.0%
Sema.AttachedPropertyWrappersRequest 1,546,521 1,546,521 0 0.0%
Sema.CustomAttrNominalRequest 1 1 0 0.0%
Sema.DefaultAndMaxAccessLevelRequest 40,399 40,399 0 0.0%
Sema.EnumRawTypeRequest 8,908 8,908 0 0.0%
Sema.ExtendedNominalRequest 830,799 830,790 -9 -0.0%
Sema.FunctionBuilderTypeRequest 1 1 0 0.0%
Sema.InheritedDeclsReferencedRequest 1,293,269 1,293,248 -21 -0.0%
Sema.InheritedTypeRequest 186,493 186,493 0 0.0%
Sema.IsDynamicRequest 1,285,388 1,285,388 0 0.0%
Sema.IsObjCRequest 1,114,715 1,114,715 0 0.0%
Sema.MangleLocalTypeDeclRequest 263 263 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 9,201 9,201 0 0.0%
Sema.NamedLazyMemberLoadSuccessCount 15,410,978 15,356,128 -54,850 -0.36%
Sema.NominalTypeLookupDirectCount 33,647,994 33,614,454 -33,540 -0.1%
Sema.NumConformancesDeserialized 3,804,791 3,804,769 -22 -0.0%
Sema.NumDeclsDeserialized 10,637,052 10,637,037 -15 -0.0%
Sema.NumDeclsFinalized 1,197,201 1,197,201 0 0.0%
Sema.NumDeclsTypechecked 1,637,086 1,637,086 0 0.0%
Sema.NumDeclsValidated 1,964,849 1,964,849 0 0.0%
Sema.NumFunctionsTypechecked 775,808 775,808 0 0.0%
Sema.NumGenericSignatureBuilders 366,315 366,315 0 0.0%
Sema.NumLazyGenericEnvironments 2,110,260 2,110,260 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 36,159 36,159 0 0.0%
Sema.NumLazyIterableDeclContexts 1,401,633 1,401,620 -13 -0.0%
Sema.NumLazyRequirementSignatures 114,552 114,551 -1 -0.0%
Sema.NumLazyRequirementSignaturesLoaded 89,204 89,204 0 0.0%
Sema.NumTypesDeserialized 5,454,957 5,454,955 -2 -0.0%
Sema.NumTypesValidated 1,159,072 1,159,072 0 0.0%
Sema.NumUnloadedLazyIterableDeclContexts 864,970 864,957 -13 -0.0%
Sema.OverriddenDeclsRequest 1,098,145 1,098,145 0 0.0%
Sema.PropertyWrapperBackingPropertyInfoRequest 176,665 176,665 0 0.0%
Sema.PropertyWrapperBackingPropertyTypeRequest 179,914 179,914 0 0.0%
Sema.PropertyWrapperTypeInfoRequest 1 1 0 0.0%
Sema.RequirementRequest 77,441 77,441 0 0.0%
Sema.SelfBoundsFromWhereClauseRequest 1,810,573 1,810,537 -36 -0.0%
Sema.SetterAccessLevelRequest 130,460 130,460 0 0.0%
Sema.SuperclassDeclRequest 101,335 101,335 0 0.0%
Sema.SuperclassTypeRequest 25,541 25,541 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 23,179 23,179 0 0.0%
Sema.USRGenerationRequest 169,546 169,546 0 0.0%
Sema.UnderlyingTypeDeclsReferencedRequest 67,268 67,268 0 0.0%

@DougGregor
Copy link
Member Author

@swift-ci build toolchain

@DougGregor DougGregor merged commit 3433727 into swiftlang:swift-5.1-branch Sep 3, 2019
@DougGregor DougGregor deleted the one-way-constraints-5.1 branch September 3, 2019 19:03
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.

4 participants