-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Use StoreAligned
not Store
in WidenAsciiToUtf16
#89892
Conversation
Tagging subscribers to this area: @dotnet/area-system-text-encoding Issue DetailsDescriptionThis PR is to improve the in-loop We are open to adjusting the implementation style for either path. Perf number attached in the comments.
|
Perf numbersBase: main (531ad95) Avx512summary:
AVXsummary: No Slower results for the provided threshold = 1% and noise filter = 0.5 ns.
SSEsummary: No Slower results for the provided threshold = 1% and noise filter = 0.5 ns.
|
src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs
Outdated
Show resolved
Hide resolved
How does this change affect UPD: @Ruihan-Yin thank you |
Thanks for pointing out. That was a mistake, changed to |
Hi @xtqqczze @neon-sunset, kindly asking if there is any further change needed? |
Perhaps we shouldn't assume the argument I'm not sure how to handle this, but runtime/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs Lines 539 to 542 in 9a5fa74
|
AFAIR the guideline is that if the platform the code is running on works with unaligned memory, dotnet APIs should work too. |
@MichalPetryka We have existing code that does not account for this, e.g. |
@tannergooding based on some of the conversation we had, I am not sure how to proceed. Perhaps we want to implement a fallback method that does not pin, and does not explicitly use |
See also comments at #90319. |
For right now we should keep the pin and try to align, but if its unalignable then we should just continue as-is. It's basically the same code just with a check for "is this alignable at all" and using For the future, we probably want to come to an agreement about how to universally handle this. My guess/vote is that's probably going to involve not pinning and using |
Just checking up on the status of this PR, @anthonycanino have you had the chance to address @tannergooding's feedback? |
@tannergooding how do we feel about this change now that we are moving to |
I don't think it's changed from my last feedback. We really need to account for unalignable data and the easiest way to do that is to pin, check the alignment, align if possible, and then continue processing using In general the code pattern for efficiently handling alignment efficiently, for idempotent data, looks something like https://source.dot.net/#System.Numerics.Tensors/System/Numerics/Tensors/TensorPrimitives.netcore.cs,2930 Using |
This pull request has been automatically marked |
This pull request will now be closed since it had been marked |
Description
This PR is to improve the in-loop
write
logic inWidenAsciiToUtf16
, the major change is to replaceStoreAligned
withStore
inside the loop to reduce the penalty caused by split loads.We are open to adjusting the implementation style for either path. Perf number attached in the comments.