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

[CSSolver] Hide witness overloads behind protocol requirements they match #13986

Closed
wants to merge 2 commits into from

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jan 17, 2018

If overload set contains both protocol requirement and its witnesses
let's only leave requirement itself active until we know that it matches,
in such case we'd re-enable witness methods and attempt them. This
helps to significantly reduce the number of overload choices we consider
upfront e.g. for '==' operator we can hide 53 choices behind Equatable
protocol from total number of 68 choices.

xedin added 2 commits January 16, 2018 15:06
…atch

If overload set contains both protocol requirement and its witnesses
let's only leave requirement itself active until we know that it matches,
in such case we'd re-enable witness methods and attempt them. This
helps to significantly reduce the number of overload choices we consider
upfront e.g. for '==' operator we can hide 53 choices behind Equatable
protocol from total number of 68 choices.
@xedin
Copy link
Contributor Author

xedin commented Jan 17, 2018

/cc @DougGregor please take a look, this implements raw folding of the witnesses behind protocol requirement overloads.

@xedin
Copy link
Contributor Author

xedin commented Jan 17, 2018

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

Build comment file:

Summary for master full

Unexpected test results, stats may be off for FAIL_Kronos-Kronos.xcodeproj_3.0_BuildXcodeProjectTarget_Kronos_generic-platform-tvOS.log, FAIL_SwiftDate-SwiftDate-SwiftDate.xcodeproj_3.0_BuildXcodeProjectScheme_SwiftDate_tvOS_generic-platform-tvOS.log, FAIL_Kronos-Kronos.xcodeproj_3.0_BuildXcodeProjectTarget_Kronos_generic-platform-iOS.log, FAIL_JSQDataSourcesKit-JSQDataSourcesKit.xcodeproj_4.0_BuildXcodeProjectTarget_JSQDataSourcesKit-iOS_generic-platform-iOS.log, FAIL_Dollar-Dollar.xcodeproj_3.0_BuildXcodeProjectScheme_Dollar_generic-platform-macOS.log, 3, FAIL_SwiftDate-SwiftDate-SwiftDate.xcodeproj_3.0_BuildXcodeProjectScheme_SwiftDate_watchOS_generic-platform-watchOS.log, FAIL_Kronos-Kronos.xcodeproj_3.0_BuildXcodeProjectTarget_Kronos_generic-platform-macOS.log, FAIL_RxDataSources-Pods-Pods.xcodeproj_3.0_BuildXcodeProjectTarget_Pods-Example_generic-platform-iOS.log, FAIL_RxDataSources-Pods-Pods.xcodeproj_3.0_BuildXcodeProjectTarget_Pods-RxDataSources_generic-platform-iOS.log, FAIL_SwiftDate-SwiftDate-SwiftDate.xcodeproj_3.0_BuildXcodeProjectScheme_SwiftDate_iOS_generic-platform-iOS.log

Regressions found (see below)

Debug

debug brief

Regressed (1)
name old new delta delta_pct
time.swift-driver.wall 1357.5s 1632.3s 274.7s 20.24% ⛔
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,001,936,032 992,041,872 -9,894,160 -0.99%

debug detailed

Regressed (8)
name old new delta delta_pct
Sema.NumConformancesDeserialized 5,532,702 8,756,479 3,223,777 58.27% ⛔
Sema.NumConstraintScopes 15,227,311 34,872,748 19,645,437 129.01% ⛔
Sema.NumDeclsDeserialized 48,059,317 51,250,583 3,191,266 6.64% ⛔
Sema.NumGenericSignatureBuilders 1,517,104 1,569,553 52,449 3.46% ⛔
Sema.NumLazyGenericEnvironments 9,362,192 10,072,276 710,084 7.58% ⛔
Sema.NumLazyGenericEnvironmentsLoaded 841,054 858,781 17,727 2.11% ⛔
Sema.NumLazyIterableDeclContexts 7,311,414 8,491,647 1,180,233 16.14% ⛔
Sema.NumTypesDeserialized 50,011,672 52,111,223 2,099,551 4.2% ⛔
Improved (2)
name old new delta delta_pct
SILModule.NumSILGenFunctions 979,626 968,106 -11,520 -1.18% ✅
SILModule.NumSILOptFunctions 1,409,253 1,390,802 -18,451 -1.31% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (13)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 1,591,972 1,588,635 -3,337 -0.21%
AST.NumLoadedModules 314,405 313,162 -1,243 -0.4%
AST.NumTotalClangImportedEntities 5,005,330 4,981,579 -23,751 -0.47%
AST.NumUsedConformances 143,844 144,147 303 0.21%
IRModule.NumIRBasicBlocks 3,187,556 3,158,188 -29,368 -0.92%
IRModule.NumIRFunctions 1,492,885 1,483,295 -9,590 -0.64%
IRModule.NumIRGlobals 1,518,845 1,506,054 -12,791 -0.84%
IRModule.NumIRInsts 32,320,765 32,107,192 -213,573 -0.66%
IRModule.NumIRValueSymbols 2,544,137 2,527,047 -17,090 -0.67%
LLVM.NumLLVMBytesOutput 1,001,936,032 992,041,872 -9,894,160 -0.99%
Sema.NumDeclsValidated 2,008,051 2,013,027 4,976 0.25%
Sema.NumFunctionsTypechecked 958,810 952,801 -6,009 -0.63%
Sema.NumTypesValidated 4,563,298 4,561,845 -1,453 -0.03%

Debug-opt

debug-opt brief

Regressed (1)
name old new delta delta_pct
time.swift-driver.wall 2420.6s 2713.8s 293.2s 12.11% ⛔
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 931,815,868 926,532,316 -5,283,552 -0.57%

debug-opt detailed

Regressed (8)
name old new delta delta_pct
Sema.NumConformancesDeserialized 10,806,043 13,873,498 3,067,455 28.39% ⛔
Sema.NumConstraintScopes 15,200,165 34,867,038 19,666,873 129.39% ⛔
Sema.NumDeclsDeserialized 52,826,037 55,751,878 2,925,841 5.54% ⛔
Sema.NumGenericSignatureBuilders 1,554,830 1,608,771 53,941 3.47% ⛔
Sema.NumLazyGenericEnvironments 10,164,098 10,822,480 658,382 6.48% ⛔
Sema.NumLazyGenericEnvironmentsLoaded 854,165 873,651 19,486 2.28% ⛔
Sema.NumLazyIterableDeclContexts 7,550,111 8,676,247 1,126,136 14.92% ⛔
Sema.NumTypesDeserialized 57,222,941 59,135,662 1,912,721 3.34% ⛔
Improved (2)
name old new delta delta_pct
SILModule.NumSILGenFunctions 977,874 967,071 -10,803 -1.1% ✅
SILModule.NumSILOptFunctions 1,923,791 1,889,375 -34,416 -1.79% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (13)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 1,588,087 1,587,858 -229 -0.01%
AST.NumLoadedModules 301,939 301,156 -783 -0.26%
AST.NumTotalClangImportedEntities 5,272,630 5,253,445 -19,185 -0.36%
AST.NumUsedConformances 143,424 144,063 639 0.45%
IRModule.NumIRBasicBlocks 2,880,493 2,859,779 -20,714 -0.72%
IRModule.NumIRFunctions 1,125,812 1,119,747 -6,065 -0.54%
IRModule.NumIRGlobals 1,231,449 1,222,700 -8,749 -0.71%
IRModule.NumIRInsts 23,729,909 23,576,250 -153,659 -0.65%
IRModule.NumIRValueSymbols 2,041,229 2,029,806 -11,423 -0.56%
LLVM.NumLLVMBytesOutput 931,815,868 926,532,316 -5,283,552 -0.57%
Sema.NumDeclsValidated 1,999,807 2,011,304 11,497 0.57%
Sema.NumFunctionsTypechecked 955,916 952,214 -3,702 -0.39%
Sema.NumTypesValidated 4,550,933 4,559,363 8,430 0.19%

Wmo-onone

wmo-onone brief

Regressed (1)
name old new delta delta_pct
time.swift-driver.wall 1345.5s 1635.4s 289.9s 21.54% ⛔
Improved (1)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 871,389,584 822,037,764 -49,351,820 -5.66% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (0)
name old new delta delta_pct

wmo-onone detailed

Regressed (8)
name old new delta delta_pct
Sema.NumConformancesDeserialized 1,208,531 1,548,356 339,825 28.12% ⛔
Sema.NumConstraintScopes 14,516,437 34,163,155 19,646,718 135.34% ⛔
Sema.NumDeclsDeserialized 4,452,138 4,577,925 125,787 2.83% ⛔
Sema.NumGenericSignatureBuilders 153,103 156,233 3,130 2.04% ⛔
Sema.NumLazyGenericEnvironments 760,017 790,321 30,304 3.99% ⛔
Sema.NumLazyGenericEnvironmentsLoaded 92,436 94,941 2,505 2.71% ⛔
Sema.NumLazyIterableDeclContexts 488,293 547,767 59,474 12.18% ⛔
Sema.NumTypesDeserialized 4,555,479 4,620,168 64,689 1.42% ⛔
Improved (12)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 185,205 183,164 -2,041 -1.1% ✅
AST.NumTotalClangImportedEntities 605,705 598,516 -7,189 -1.19% ✅
IRModule.NumIRBasicBlocks 2,602,352 2,500,625 -101,727 -3.91% ✅
IRModule.NumIRFunctions 1,272,374 1,243,375 -28,999 -2.28% ✅
IRModule.NumIRGlobals 1,236,106 1,197,255 -38,851 -3.14% ✅
IRModule.NumIRInsts 28,923,662 28,227,771 -695,891 -2.41% ✅
IRModule.NumIRValueSymbols 2,135,136 2,084,397 -50,739 -2.38% ✅
LLVM.NumLLVMBytesOutput 871,389,584 822,037,764 -49,351,820 -5.66% ✅
SILModule.NumSILGenFunctions 518,053 500,922 -17,131 -3.31% ✅
SILModule.NumSILOptFunctions 565,015 545,297 -19,718 -3.49% ✅
Sema.NumDeclsValidated 877,651 863,980 -13,671 -1.56% ✅
Sema.NumTypesValidated 1,072,767 1,049,948 -22,819 -2.13% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
AST.NumLoadedModules 10,647 10,597 -50 -0.47%
AST.NumUsedConformances 147,790 148,119 329 0.22%
Sema.NumFunctionsTypechecked 285,222 283,343 -1,879 -0.66%

Release

release brief

Regressed (1)
name old new delta delta_pct
time.swift-driver.wall 2854.3s 3034.3s 180.1s 6.31% ⛔
Improved (1)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 935,446,680 913,344,936 -22,101,744 -2.36% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (0)
name old new delta delta_pct

release detailed

Regressed (8)
name old new delta delta_pct
Sema.NumConformancesDeserialized 3,785,932 4,588,431 802,499 21.2% ⛔
Sema.NumConstraintScopes 14,812,133 34,472,285 19,660,152 132.73% ⛔
Sema.NumDeclsDeserialized 13,361,261 14,004,122 642,861 4.81% ⛔
Sema.NumGenericSignatureBuilders 464,840 485,705 20,865 4.49% ⛔
Sema.NumLazyGenericEnvironments 2,487,810 2,637,618 149,808 6.02% ⛔
Sema.NumLazyGenericEnvironmentsLoaded 238,726 244,005 5,279 2.21% ⛔
Sema.NumLazyIterableDeclContexts 1,831,746 2,099,885 268,139 14.64% ⛔
Sema.NumTypesDeserialized 14,940,649 15,340,823 400,174 2.68% ⛔
Improved (8)
name old new delta delta_pct
IRModule.NumIRBasicBlocks 2,748,161 2,678,312 -69,849 -2.54% ✅
IRModule.NumIRFunctions 1,122,843 1,099,958 -22,885 -2.04% ✅
IRModule.NumIRGlobals 1,295,275 1,259,465 -35,810 -2.76% ✅
IRModule.NumIRInsts 23,889,052 23,362,769 -526,283 -2.2% ✅
IRModule.NumIRValueSymbols 2,091,169 2,046,525 -44,644 -2.13% ✅
LLVM.NumLLVMBytesOutput 935,446,680 913,344,936 -22,101,744 -2.36% ✅
SILModule.NumSILGenFunctions 555,207 538,385 -16,822 -3.03% ✅
SILModule.NumSILOptFunctions 981,763 951,445 -30,318 -3.09% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (7)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 470,272 473,061 2,789 0.59%
AST.NumLoadedModules 58,181 58,133 -48 -0.08%
AST.NumTotalClangImportedEntities 1,596,648 1,597,212 564 0.04%
AST.NumUsedConformances 150,994 151,333 339 0.22%
Sema.NumDeclsValidated 1,087,933 1,084,324 -3,609 -0.33%
Sema.NumFunctionsTypechecked 418,802 416,923 -1,879 -0.45%
Sema.NumTypesValidated 2,039,009 2,033,637 -5,372 -0.26%

@xedin
Copy link
Contributor Author

xedin commented Jan 17, 2018

@swift-ci please test source compatibility

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test compiler performance

@slavapestov
Copy link
Contributor

@xedin I've never had much luck with the full perf test, but smoke test seems to work most of the time.

@slavapestov
Copy link
Contributor

@xedin But in this case at least it looks like the failures are real :)

Eg,

/Users/buildnode/jenkins/workspace-private/swift-PR-source-compat-suite/project_cache/SwiftDate/Sources/SwiftDate/DateInRegion+Components.swift:230:57: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
                let hour = Double(utc.hour) + Double(utc.minute)/60.0 + (Double(utc.second)+Double(utc.nanosecond)/1e9)/3600.0
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@xedin
Copy link
Contributor Author

xedin commented Jan 19, 2018

@slavapestov Thanks! This needs some more work, just wanted to get preliminary numbers since stdlib compiled successfully :)

@swift-ci
Copy link
Contributor

Build comment file:

Summary for master smoketest

Unexpected test results, stats may be off for 3

Regressions found (see below)

Debug

debug brief

Regressed (0)
name old new delta delta_pct
Improved (2)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 41,040,508 37,848,056 -3,192,452 -7.78% ✅
time.swift-driver.wall 41.1s 35.2s -5.8s -14.24% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (0)
name old new delta delta_pct

debug detailed

Regressed (2)
name old new delta delta_pct
Sema.NumConformancesDeserialized 156,438 206,343 49,905 31.9% ⛔
Sema.NumLazyIterableDeclContexts 212,662 220,073 7,411 3.48% ⛔
Improved (21)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 59,956 52,740 -7,216 -12.04% ✅
AST.NumLoadedModules 9,125 8,422 -703 -7.7% ✅
AST.NumTotalClangImportedEntities 166,656 146,030 -20,626 -12.38% ✅
AST.NumUsedConformances 3,956 3,562 -394 -9.96% ✅
IRModule.NumIRBasicBlocks 103,132 91,844 -11,288 -10.95% ✅
IRModule.NumIRFunctions 55,124 49,746 -5,378 -9.76% ✅
IRModule.NumIRGlobals 77,017 69,204 -7,813 -10.14% ✅
IRModule.NumIRInsts 1,203,877 1,098,793 -105,084 -8.73% ✅
IRModule.NumIRValueSymbols 109,799 98,864 -10,935 -9.96% ✅
LLVM.NumLLVMBytesOutput 41,040,508 37,848,056 -3,192,452 -7.78% ✅
SILModule.NumSILGenFunctions 66,739 58,119 -8,620 -12.92% ✅
SILModule.NumSILOptFunctions 48,446 41,289 -7,157 -14.77% ✅
Sema.NumConstraintScopes 492,507 249,525 -242,982 -49.34% ✅
Sema.NumDeclsDeserialized 1,282,579 1,213,139 -69,440 -5.41% ✅
Sema.NumDeclsValidated 42,618 39,376 -3,242 -7.61% ✅
Sema.NumFunctionsTypechecked 35,806 31,661 -4,145 -11.58% ✅
Sema.NumGenericSignatureBuilders 54,899 51,853 -3,046 -5.55% ✅
Sema.NumLazyGenericEnvironments 231,977 223,801 -8,176 -3.52% ✅
Sema.NumLazyGenericEnvironmentsLoaded 26,088 24,443 -1,645 -6.31% ✅
Sema.NumTypesDeserialized 1,329,643 1,235,666 -93,977 -7.07% ✅
Sema.NumTypesValidated 173,395 168,440 -4,955 -2.86% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (0)
name old new delta delta_pct

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (2)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 40,671,436 34,266,640 -6,404,796 -15.75% ✅
time.swift-driver.wall 93.1s 75.7s -17.4s -18.7% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (0)
name old new delta delta_pct

release detailed

Regressed (0)
name old new delta delta_pct
Improved (22)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 10,391 8,887 -1,504 -14.47% ✅
AST.NumLoadedModules 365 334 -31 -8.49% ✅
AST.NumTotalClangImportedEntities 31,650 26,901 -4,749 -15.0% ✅
AST.NumUsedConformances 4,349 3,957 -392 -9.01% ✅
IRModule.NumIRBasicBlocks 86,826 68,241 -18,585 -21.4% ✅
IRModule.NumIRFunctions 37,742 31,437 -6,305 -16.71% ✅
IRModule.NumIRGlobals 48,854 39,397 -9,457 -19.36% ✅
IRModule.NumIRInsts 848,137 699,539 -148,598 -17.52% ✅
IRModule.NumIRValueSymbols 77,459 63,301 -14,158 -18.28% ✅
LLVM.NumLLVMBytesOutput 40,671,436 34,266,640 -6,404,796 -15.75% ✅
SILModule.NumSILGenFunctions 21,831 16,127 -5,704 -26.13% ✅
SILModule.NumSILOptFunctions 27,877 21,744 -6,133 -22.0% ✅
Sema.NumConformancesDeserialized 84,850 78,448 -6,402 -7.55% ✅
Sema.NumConstraintScopes 481,679 242,181 -239,498 -49.72% ✅
Sema.NumDeclsDeserialized 199,366 180,824 -18,542 -9.3% ✅
Sema.NumDeclsValidated 28,033 26,017 -2,016 -7.19% ✅
Sema.NumFunctionsTypechecked 11,257 10,069 -1,188 -10.55% ✅
Sema.NumGenericSignatureBuilders 7,676 7,249 -427 -5.56% ✅
Sema.NumLazyGenericEnvironments 32,713 31,134 -1,579 -4.83% ✅
Sema.NumLazyGenericEnvironmentsLoaded 3,990 3,750 -240 -6.02% ✅
Sema.NumTypesDeserialized 232,377 204,439 -27,938 -12.02% ✅
Sema.NumTypesValidated 56,823 55,281 -1,542 -2.71% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (1)
name old new delta delta_pct
Sema.NumLazyIterableDeclContexts 20,839 20,947 108 0.52%

@jrose-apple
Copy link
Contributor

Again, this is technically a behavior change. I would appreciate a test case that shows we're acknowledging that.

@xedin
Copy link
Contributor Author

xedin commented Jan 30, 2018

@jrose-apple Absolutely! I'm just trying to figure out if this is going to work at all, but at the end of the day, I'll absolutely try to come up with such test-case and add it to the suite.

@xedin xedin closed this Mar 14, 2018
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