Skip to content

Add swift_getTypeByMangledNameInContextInMetadataState such that we can #28337

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

Conversation

aschwaighofer
Copy link
Contributor

use getTypeByMangledName when abstract metadata state is requested

This can significantly reduce the code size of apps constructing deeply
nested types with conditional conformances.

Requires a new runtime.

rdar://57157619

use getTypeByMangledName when abstract metadata state is requested

This can significantly reduce the code size of apps constructing deeply
nested types with conditional conformances.

Requires a new runtime.

rdar://57157619
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0d324d2

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 0d324d2

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 0d324d2

auto instantiationFnName =
request.isStaticallyAbstract()
? "__swift_instantiateConcreteTypeFromMangledNameAbstract"
: "__swift_instantiateConcreteTypeFromMangledName";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this, Arnold! I wonder whether, if we're targeting Swift >= 5.2, we could only emit __swift_instantiateConcreteTypeFromMangledNameAbstract and use it for all metadata requests. That would probably mean a couple more instructions at call sites to materialize the metadata request kind argument, though.

RETURNS(TypeMetadataPtrTy),
ARGS(SizeTy, Int8PtrTy, SizeTy, TypeContextDescriptorPtrTy,
Int8PtrPtrTy),
ATTRS(NoUnwind, ArgMemOnly))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd also be good to add the swift_getTypeByMangledNameInEnvironmentInMetadataState variant, so we have it available for future use to instantiate metadata in generic environments that don't have an associated type context.

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 44b99b7

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 44b99b7

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 84bb456

@aschwaighofer
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 84bb456

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 84bb456

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test linux

@airspeedswift
Copy link
Member

@swift-ci please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
ObjectiveCBridgeStubFromNSDateRef 3830 4200 +9.7% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
FlattenListLoop 5295 4453 -15.9% 1.19x (?)
FlattenListFlatMap 10291 8988 -12.7% 1.14x (?)
AngryPhonebook.Cyrillic.Small 932 853 -8.5% 1.09x (?)

Code size: -O

Performance: -Osize

Improvement OLD NEW DELTA RATIO
ObjectiveCBridgeStubFromNSDateRef 4220 3800 -10.0% 1.11x (?)

Code size: -Osize

Performance: -Onone

Regression OLD NEW DELTA RATIO
AngryPhonebook 2996 3458 +15.4% 0.87x (?)
AngryPhonebook.ASCII.Small 131 150 +14.5% 0.87x (?)
DataAppendDataSmallToSmall 4080 4480 +9.8% 0.91x (?)
NormalizedIterator_ascii 474 520 +9.7% 0.91x (?)
CharIndexing_chinese_unicodeScalars_Backwards 439640 481200 +9.5% 0.91x (?)
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 101000 108920 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
FloatingPointPrinting_Float_interpolated 60800 54800 -9.9% 1.11x (?)
ObjectiveCBridgeStubFromNSDateRef 4830 4370 -9.5% 1.11x (?)

Code size: -swiftlibs

How to read the data The 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
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

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