-
Notifications
You must be signed in to change notification settings - Fork 281
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
Perf | Reduce memory allocations in SerializeEncodingChar/WriteEncodingChar and some options boxing #785
Conversation
1dc5113
to
ea89a52
Compare
The test that is failing seems to be unrelated to my change: |
The HasFlags changes aren't needed and I put them in because I was advised to by the jit team because HasFlags is a jit intrinsic on netcore2.1 and later and gets optimized out. sharplab example compare the il and asm in release and you'll see the box is totally removed. If you're using netfx then you've got a lot bigger problems with memory than these calls. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
@Wraith2 ok, i've reverted that change. is there a blog post or documentation on the jit optimization/intrinsic you are referring to? (n/m found a writeup). ... i don't see the advantage of |
It's covered in this blog post https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-core-2-1/ but I found it while reviewing PR's in the runtime repo where it was suggested to use HasFlag instead of the masking. The advantage is that the jit sees the call and has a direct transformation for it instead of relying on the translation and simplification steps that should result in the same codegen but might not. |
these changes reduce unnecessary memory allocations which results in decreased memory pressure on the garbage collector and better performance. the changes are all localized so hopefully are easy to review and accept.