-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Frontend] Add experimental flag to skip non-inlinable function bodies #20420
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
[Frontend] Add experimental flag to skip non-inlinable function bodies #20420
Conversation
@swift-ci please benchmark |
@swift-ci please test |
Build failed |
This comment has been minimized.
This comment has been minimized.
Okay, looks like I’m missing some specializations or some inlinable code. |
The Linux failures might shed some light on what I'm missing:
|
3225a1b
to
c9d5ae9
Compare
Oops! Was skipping inlinable deinitializers. @swift-ci please benchmark |
This comment has been minimized.
This comment has been minimized.
Still missing something... |
@swift-ci please smoke test linux platform |
c9d5ae9
to
844f2b4
Compare
This comment has been minimized.
This comment has been minimized.
63219f7
to
1345e0c
Compare
Just gonna kick off another benchmarking run with @jrose-apple's recent pointer-related changes in #21126. @swift-ci please benchmark |
@swift-ci please smoke test |
This comment has been minimized.
This comment has been minimized.
Seems that wasn't it. |
9758aca
to
c5c6308
Compare
Running again just disabling the optimization for SwiftOnoneSupport. @swift-ci please benchmark |
@swift-ci please benchmark |
Build comment file:Build failed before running benchmark. |
c5c6308
to
de5a916
Compare
@swift-ci please benchmark |
This comment has been minimized.
This comment has been minimized.
de5a916
to
c4d1a3e
Compare
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -OnoneCode size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
4dad42d
to
e650656
Compare
@swift-ci please smoke test |
e650656
to
8aaed26
Compare
@swift-ci please smoke test |
9979d1d
to
d39984d
Compare
@swift-ci please test |
This doesn’t need to be a method, since it’s now only going to be used in the Decl checker
d39984d
to
ac31d39
Compare
This flag, currently staged in as `-experimental-skip-non-inlinable-function-bodies`, will cause the typechecker to skip typechecking bodies of functions that will not be serialized in the resulting `.swiftmodule`. This patch also includes a SIL verifier that ensures that we don’t accidentally include a body that we should have skipped. There is still some work left to make sure the emitted .swiftmodule is exactly the same as what’s emitted without the flag, which is what’s causing the benchmark noise above. I’ll be committing follow-up patches to address those, but for now I’m going to land the implementation behind a flag.
ac31d39
to
b904133
Compare
@swift-ci please test |
def experimental_skip_non_inlinable_function_bodies: | ||
Flag<["-"], "experimental-skip-non-inlinable-function-bodies">, | ||
Flags<[FrontendOption, HelpHidden]>, | ||
HelpText<"Skip type-checking and SIL generation for non-inlinable function bodies">; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: why is this in the middle of all the stats options?
(Also, why is it a Driver option again?)
// FIXME: We can probably skip property initializers, too. | ||
auto func = F.getLocation().getAsASTNode<AbstractFunctionDecl>(); | ||
if (!func) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this scares me. All sorts of synthesized things will slip through here too.
|
||
// Local function bodies in inlinable code are okay to show up in the module. | ||
if (func->getDeclContext()->isLocalContext()) | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth checking that the enclosing context is in fact inlinable.
|
||
bool canSkipNonInlinableBodies() const { | ||
return SkipNonInlinableFunctionBodies; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: why does this need a getter and setter?
// 2. Emit the SIL for a module and check it against the expected strings in function bodies. | ||
// If we're doing the right skipping, then the strings that are CHECK-NOT'd won't have been typechecked or SILGen'd. | ||
|
||
// RUN: %target-swift-frontend -emit-sil -O -experimental-skip-non-inlinable-function-bodies %s 2>&1 | %FileCheck %s --check-prefixes CHECK,CHECK-SIL-ONLY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you didn't end up using CHECK-SIL-ONLY.
// 3. Emit the module interface while skipping non-inlinable function bodies. Check it against the same set of strings. | ||
|
||
// RUN: %target-swift-frontend -typecheck %s -enable-library-evolution -emit-module-interface-path %t/Module.skipping.swiftinterface -experimental-skip-non-inlinable-function-bodies | ||
// RUN: %FileCheck %s --check-prefixes CHECK,CHECK-INTERFACE-ONLY < %t/Module.skipping.swiftinterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…or CHECK-INTERFACE-ONLY
This patch adds an experimental flag to skip non-inlinable function
bodies and turns it on for the standard library and overlay
.swiftmodules
.This flag is disabled if the requested action generates IR.
This option causes some small improvements in the time it takes to type check and generate an optimized and unoptimized standard library
.swiftmodule
-emit-parseable-module-interface
-emit-module
-Onone
-emit-module
-O
However, since the standard library is full of inlinable code, it doesn't benefit much from skipping non-inlinable code.
To find a more representative Swift project with little inlinable code, I ran these benchmarks against the current master of SwiftLint, which shows much stronger wins:
-emit-parseable-module-interface
-emit-module
-Onone
-emit-module
-O