Skip to content

[swift-4.0] Fix SIL serialization of witness tables and protocol witness thunks #10384

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 5 commits into from
Jun 26, 2017

Conversation

swiftix
Copy link
Contributor

@swiftix swiftix commented Jun 19, 2017

Serialize witness tables only if it -sil-serialize-all or -sil-serialize-witness-tables options are provided, which should happen only when building the stdlib and overlays, or it is a compilation with explicitly enabled resilience support. Disable serialization of witness tables in all other cases.

Disabling the serialization of witness tables also avoids serialization of protocol witness thunks, whose serialization in 3rd party code sometimes resulted in performance degradation, because resilience checking rules used by many parts of the compiler would prohibit certain optimizations like inlining or specialization, if the caller was serialized and the callee would not be serialized.

• Explanation: This is fix to recover the performance regression reported for Beta1.

• Scope of Issue: Compiling a 3rd party code that does not use resilience may result in performance degradation, because some optimizations like specialization or inlining could be skipped due to some serialization related checks.

• Origination: rdar://32718853 by an external developer

• Risk: Low. It restricts SIL serialization of witness tables and protocol witness thunks.

This should fix rdar://32718853

slavapestov and others added 5 commits June 19, 2017 13:54
…und.

- SILSerializeAll flag is now stored in the SILOptions and passed around as part of it
- Explicit SILSerializeAll/wholeModuleSerialized/makeModuleFragile API parameters are removed in many places
…alization of SIL witness tables

This option is supposed to be used only for compiling overlays. User code should never be compiled with this option.
Serialize witness tables only if it -sil-serialize-all or -sil-serialize-witness-tables options are provided, which should happen only when building the stdlib and overlays, or it is a compilation with explicitly enabled resilience support. Disable serialization of witness tables in all other cases.

Disabling the serialization of witness tables also avoids serialization of protocol witness thunks, whose serialization in 3rd party code sometimes resulted in performance degradation, because resilience checking rules used by many parts of the compiler would prohibit certain optimizations like inlining or specialization, if the caller was serialized and the callee would not be serialized.

This should fix rdar://32718853   and address rdar://32743391
@swiftix swiftix requested a review from slavapestov June 19, 2017 21:16
@swiftix
Copy link
Contributor Author

swiftix commented Jun 19, 2017

@swift-ci please test

@slavapestov
Copy link
Contributor

LGTM!

@slavapestov
Copy link
Contributor

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Build comment file:

Build failed before running benchmark.


@shahmishal
Copy link
Member

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Build comment file:

Build failed before running benchmark.


@shahmishal
Copy link
Member

@swift-ci Please benchmark

@swiftix
Copy link
Contributor Author

swiftix commented Jun 20, 2017

@swift-ci please smoke test

1 similar comment
@swiftix
Copy link
Contributor Author

swiftix commented Jun 20, 2017

@swift-ci please smoke test

@swift-ci
Copy link
Contributor

Build comment file:

Build failed before running benchmark.


@shahmishal
Copy link
Member

@swiftix We don't currently support swift-4.0-branch benchmark testing, its only supported on master branch at this time. I will look into fixing this issue soon. Thanks!

@swiftlang swiftlang deleted a comment from swift-ci Jun 21, 2017
@swiftlang swiftlang deleted a comment from swift-ci Jun 21, 2017
@eeckstein
Copy link
Contributor

I'll run the benchmarks locally

@huonw huonw mentioned this pull request Jun 22, 2017
@huonw
Copy link
Contributor

huonw commented Jun 22, 2017

What's the status of this? (I'm waiting on it for #10482.)

@huonw
Copy link
Contributor

huonw commented Jun 23, 2017

I'm informed that @swiftix is on vacation for a while, is someone else on @bob-wilson's team going to take over getting this in? (I'm not literally blocked, but the master equivalent of #10482 was rebased in a moderately non-trivial way over the master equivalent of this, so that PR is set up assuming the same will happen.)

@shahmishal
Copy link
Member

I think @eeckstein was following up on this PR.

@eeckstein
Copy link
Contributor

Yes, I still want to run benchmarks (locally).
I was quite busy today with other bug fixes. I hope that I can do it on Monday.

@eeckstein
Copy link
Contributor

I did run the benchmarks locally and saw this regressions:

Regression (12):
TEST OLD NEW DELTA SPEEDUP

StringHasPrefix 15 30 +100.0% 0.50x
StringHasSuffix 15 30 +100.0% 0.50x
DictionaryHashableStruct 1167 1938 +66.1% 0.60x
ProtocolDispatch 2229 2786 +25.0% 0.80x

I'd like to investigate this before I merge

@huonw Does this block you?

@eeckstein
Copy link
Contributor

Ok, I turns out that those regressions are not real.

@tkremenek tkremenek merged commit 59ed33d into swiftlang:swift-4.0-branch Jun 26, 2017
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.

7 participants