Skip to content
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

[Minor optimisation] Potential for optimisation in WriteToServer (SqlMetaDataPriv.IsNullable) #1076

Closed
thibault-reigner opened this issue May 19, 2021 · 4 comments · Fixed by #1054 or #1064
Labels
💡 Enhancement Issues that are feature requests for the drivers we maintain. 📈 Performance Issues that are targeted to performance improvements.

Comments

@thibault-reigner
Copy link

thibault-reigner commented May 19, 2021

Hello,

While working on a project I have observed through DotTrace an opportunity to quickly get some better performance in WriteToServer :
Framework version : Net Framework 4.7.2
Microsoft.Data.SqlClient version : 2.1.2

image

As one can see, the HasFlag method used in SqlMetaDataPriv.IsNullable triggers some boxing and extra computation. I guess a solution like the one mentioned here https://medium.com/@arphox/the-boxing-overhead-of-the-enum-hasflag-method-c62a0841c25a
would result in some interesting performance gain as overall the method takes 0.41% of 9.18%, so ~4.5% of the WriteToServer method). This proportion could technically be higher since GetValueFromSourceRow calls the IDataReader supplied by the client code, whose performance could be better than the one from my example above and hence increase the relative proportion of ConvertValue and IsNullable.

@JRahnama JRahnama added 💡 Enhancement Issues that are feature requests for the drivers we maintain. 📈 Performance Issues that are targeted to performance improvements. labels May 19, 2021
@JRahnama
Copy link
Contributor

@thibault-reigner thanks for sharing your idea to this repo. Can you make a PR for the suggested improvement otherwise we will get back to this in future when we have time.

@roji
Copy link
Member

roji commented May 19, 2021

/cc @Wraith2 I think you were looking at this recently

@cheenamalhotra
Copy link
Member

PR #1054

@Wraith2
Copy link
Contributor

Wraith2 commented May 19, 2021

And #1064

From what I was told netcore 3.1 should generate masking for the HasFlag extension and that change was made in corefx when the code was only going to be used from netcore. I have seen this turn up on my own traces even under netcore so I'm not sure why it's not generating the same code as it would in sharplab. Manual flags is more compatible and doesn't box so everything will get switched over as soon as we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Enhancement Issues that are feature requests for the drivers we maintain. 📈 Performance Issues that are targeted to performance improvements.
Projects
None yet
5 participants