-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Runtime] Have ConcurrentReadableHashMap store indices inline when the table is sufficiently small. #34463
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] Have ConcurrentReadableHashMap store indices inline when the table is sufficiently small. #34463
Conversation
…e table is sufficiently small.
@swift-ci please benchmark |
@swift-ci please test |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -Onone
Code 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
|
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.
Make sense to me!
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.
LGTM
Thanks for checking it over! This doesn't produce the performance win I was hoping for (fewer dependent memory accesses resulting in a minor boost) but as long as it's not a significant slowdown, it's worth it for the memory savings alone. I'm going to re-test and then get it in. |
@swift-ci please test |
@swift-ci please test windows platform |
We use the lower two bits of the indices value to indicate the index size and inline-ness. When stored inline, we can pack 7 or 15 (on 32-bit and 64-bit respectively) values inline, meaning we don't need a heap allocation until we exceed that size, and avoiding the cost of an additional read in those cases.