Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork754
Perf: UseSpan.CopyTo<Byte>() on .NET 7 and above.#2170
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Perf: UseSpan.CopyTo<Byte>() on .NET 7 and above.#2170
Conversation
This changes `UnsafeMemory` to use the safe equivalents in .NET 7 and above as they are moreperformant than the equivalent code and can take advantage of vectorization on hardware that supports it
Span.CopyTo<Byte>() on .NET 7 and above.Span.CopyTo<Byte>() on .NET 7 and above.AArnott commentedMar 2, 2025
Thanks for this. But we don't need the Can you just replace the old code with the new code? And then we should definitely get@neuecc's review (and maybe@pCYSl5EDgo) because they've done a lot of micro-optimization work in this library. |
jkrejcha commentedMar 3, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Alright. It looks like .NET 7 and below doesn't have the optimization anyway potentially (it replaces with a call to Output on .NET 8 vs. .NET 7 |
AArnott commentedMar 3, 2025
Thanks. Two more thoughts. So long as you're looking at native assembly emitted, can you look at .NET Framework? That's important too. If this really is going to be the way to go, I guess we can get rid of all the many methods that you're changing too, as they were named and implemented specially for the length of the span, and that evidently isn't necessary any more since their implementations are now identical. But feel free to wait for@neuecc's take before doing more work, since he may know something about why this isn't doable in the first place. Unity is another target runtime and it may be important there that the code remains as-is, for example. |
neuecc commentedMar 4, 2025
This seems like a remnant from an era before Span existed. |
neuecc commentedMar 4, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
In the end, it goes to SpanHelpers.memmove? |
neuecc commentedMar 4, 2025
Minimal benchmarking shows that Span is better than the original. |
This changes
UnsafeMemoryto use the safe equivalents in .NET 7 and above as they are more performant than the equivalent code and can take advantage of vectorization on hardware that supports itThis optimization exists on at least .NET 7.