-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Runtime] Cache protocol conformance descriptors, not witness tables. #20491
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
[Runtime] Cache protocol conformance descriptors, not witness tables. #20491
Conversation
@swift-ci please smoke test |
@swift-ci please benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How 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
|
@swift-ci please smoke test Linux |
… contexts When a (file)private entity occurs inside a generic context, we still need information about the genericity of the enclosing context to demangle to metadata. Emit complete context descriptors for parents of anonymous contexts. Fixes rdar://problem/46109026.
0770929
to
17699d4
Compare
The conformance cache was caching the witness table for a conformance `T: P`, where `T` is a concrete type and `P` is a protocol. However, it essentially picked one of potentially many witness tables for that conformance, because retroactive conformances might produce different results from different modules. Make the conformance cache what is says it is: a cache of the conformance descriptor for a given `T: P`, potentially filtered by a module (when requested). Clients of the conformance cache can choose how to interpret the protocol conformance descriptor, e.g., by instantiating a witness table. We can bring back a specific conformance cache for swift_conformsToProtocol() if it is profitable. (cherry picked from commit 0af2af00a739a4d912d2a9c3b196449e4164484f)
@swift-ci please smoke test |
…metadata. Metadata uniquing might encounter witness tables that were distinctly generated but come from identical descriptors. Handle this case in metadata uniquing be looking into the protocol conformance descriptors themselves.
@swift-ci please smoke test |
This reverts commit 6abc848.
@swift-ci please smoke test |
@swift-ci please benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How 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
|
Benchmark regressions imply that the code comparing two metadata cache keys is hot, given that it's so much slower now. We can certainly improve things there with (e.g.) some kind of run-length encoding for sequences of exact pointer comparisons and sequences of witness table comparisons. |
Rather than scanning the type descriptor each time we perform a comparison or hash of a metadata cache entry, do so only once to establish the number of key parameters and the number of witness tables. Use those values to more efficiently compare keys.
@swift-ci please benchmark |
@swift-ci please smoke test |
1 similar comment
@swift-ci please smoke test |
@swift-ci please benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How 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
|
Rather than scanning through the generic parameters and generic requirements each time we form a key for the generic metadata cache, compute these values once, when the cache itself is first initialized.
@swift-ci please benchmark |
@swift-ci please smoke test |
@swift-ci please benchmark |
@swift-ci please smoke test |
@swift-ci please smoke test Linux |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How 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
|
The conformance cache was caching the witness table for a conformance
T: P
, whereT
is a concrete type andP
is a protocol. However, itessentially picked one of potentially many witness tables for that
conformance, because retroactive conformances might produce different results
from different modules.
Make the conformance cache what is says it is: a cache of the conformance
descriptor for a given
T: P
. Clients of the conformance cache can choose how to interpretthe protocol conformance descriptor, e.g., by instantiating a witness table with a
particular set of arguments.
We can bring back a specific conformance cache for
swift_conformsToProtocol()
if it is profitable.