-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Switch grapheme break property searching to Eytzinger binary search #71668
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
Switch grapheme break property searching to Eytzinger binary search #71668
Conversation
@swift-ci please test |
@swift-ci Please Apple Silicon benchmark |
3123ce4
to
d8f47a5
Compare
@swift-ci please test |
@swift-ci Please Apple Silicon benchmark |
Preliminary results look nice
|
128-byte aligning the array is ever so slightly slower, so no need to change that |
@swift-ci Please Apple Silicon benchmark |
@swift-ci please test |
Now THIS is pod racing
|
@swift-ci Please Apple Silicon benchmark |
@swift-ci please test |
case v | ||
case zwj | ||
|
||
@inline(__always) |
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.
The purpose of making sure this gets inlined is to allow the compiler enough visibility to combine the switch statement here with the switch statement in the caller, rather than going switch -> flag -> switch
|
||
//If we want the left child of the current node in our virtual tree, | ||
//that's at index * 2, if we want the right child it's at (index * 2) + 1 | ||
if (scalar < lower) { |
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.
This branch could be hoisted above fetching upper
and enumValue
, but the optimizer successfully does that for us, and it reads better this way
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.
Overall LGTM but I'd like @Azoy to review as well
#include "swift/shims/UnicodeData.h" | ||
#include <limits> | ||
|
||
|
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.
@Azoy could you look over the changes to the C++ code and the strategy used?
0x8061F23C, 0xB621F249, 0x2081F3FB, 0xA7A1F400, 0xA121F546, 0x8FE1F680, 0x8161F774, 0x8541F7D5, | ||
0x8061F80C, 0x80E1F848, 0x80A1F85A, 0x80E1F888, 0x8A21F8AE, 0x85C1F90C, 0x8121F93C, 0xB701F947, | ||
0x3EE0000, 0x2BEE0020, 0xFEE0080, 0x3DEE0100, | ||
static const __swift_uint32_t _swift_stdlib_graphemeBreakProperties[638] = { |
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.
You don't really need the dummy 0th element, but also it doesn't really matter =)
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.
But the 4 bytes of binary size Steve!
Co-authored-by: Michael Ilseman <[email protected]>
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.
This is wonderful! Apart from what Michael has already mentioned, everything here looks good to me!
@swift-ci please test |
@swift-ci please test |
Fixes rdar://123055338