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
stdlib: Code size improvements for Dictionary for -Osize #21306
Conversation
@swift-ci benchmark |
Build comment file:Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Performance: -Onone
Code size: -swiftlibs
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 test |
Build failed |
Build failed |
…ion when compiled with -Osize It's @_semantics("optimize.sil.specialize.generic.size.never") It is similar to "optimize.sil.specialize.generic.partial.never", but only prevents specialization if the optimization mode is Size
The first change is to remove some @inline(__always) attributes. Those were added before we had the guaranteed-by-default calling convention. They are not necessary anymore. The second change is to not specialize some slow-path functions. This results that no specialization code for these functions is generated at the client side. Instead those functions are directly called in the libSwiftCore. Note that Key-related hash and equality comparisons are still specialized, because otherwise the performance hit for Osize would be too big. Some Dictionary benchmarks regress a bit with -Osize, but the code size wins are big. rdar://problem/46534453
16fcc3e
to
aae60ff
Compare
@swift-ci test |
1 similar comment
@swift-ci test |
Hm; I wonder if some of these would better be implemented by moving methods that don't depend on Key/Value to a non-generic _CoreNativeDictionary struct. |
As I see it, all of the functions I annotated depend on the Value type. |
Any idea what's causing the two -O performance regressions? Is it the removal of And the -O code size regressions seem particularly surprising, given that this change should produce less code, not more. |
The -O regressions could be noise (I didn't see them when running the benchmarks locally), e.g. because of different code alignment. |
Any idea what's going on with the "Code size: -O" regressions? For example, |
This is a result of different inlining decisions |
The first change is to remove some @inline(__always) attributes. Those were added before we had the guaranteed-by-default calling convention. They are not necessary anymore.
The second change is to not specialize some slow-path functions. This results that no specialization code for these functions is generated at the client side. Instead those functions are directly called in the libSwiftCore.
Note that Key-related hash and equality comparisons are still specialized, because otherwise the performance hit for Osize would be too big.
Some Dictionary benchmarks regress a bit with -Osize, but the code size wins are big.
rdar://problem/46534453