-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix failure of AVX2-accelerated mb_check_encoding on 32-bit MS Windows #10776
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
same instruction is used in
php-src/ext/hash/xxhash/xxhash.h
Line 3895 in 7638640
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.
Indeed.
I don't know if the AVX2-accelerated code you are showing from xxhash is used on 32-bit Windows hosts or not. If it is, that indicates that using
_mm256_set_epi64x
is not necessarily a problem in of itself. Whatever the case, a root-cause analysis cannot be done without access to a test machine, and I don't have one. However, the change in this PR seems to have fixed a problem.If anyone else has more insight into the issue at hand, I would love to hear their comments.
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.
Should we use an
#if
and keep using_mm256_set_epi64x
for everything but Windows x86 32-bit?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.
seems to be https://stackoverflow.com/questions/37509129/potential-bug-in-visual-studio-c-compiler-or-in-intel-intrinsics-avx2-mm256-s and xxhash should be fixed as well
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.
@mvorisek Good find, that explains it 🙂
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.
@mvorisek Great find!!
As a suggestion, I think the first thing would be to add a test case which exposes the problem on 32-bit Windows. Then it will be easy to verify the fix.
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.
I don't think so.
If this particular line was performance-critical, then I would say yes, but I think the performance loss here will be minute. (If the compiler is smart enough to generate optimal code on x86-64, we won't lose anything.) The effect will only be on 7 and 8 byte UTF-8 strings, and for those, I expect the overhead of entering/exiting a function from PHP code will dominate this tiny bit of overhead.
Having a lot of
#if
s in C code is a bad thing. I'm sure you know all the reasons why that is so.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.
@iluuu1994 Please note, I would be happy to be proved wrong on the above statement.
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.
I wouldn't consider an
#if
an issue, but I'm fine either way 🙂