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

Simplify internal async callback code #2091

Merged
merged 4 commits into from
Aug 9, 2023

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Jul 20, 2023

In previous PR's I optimized async paths to use state objects and cached delegates to static functions to avoid instance delegate invocations. The c# compiler now implements delegate caching directly for static lambdas and produces easier to read code. This PR converts the existing manual delegate caching to the compiler provided method.

It converts ExecuteXmlReaderAsync to use the cached context object pattern.
It converts ExecuteNonQueryAsync to use a cached context object, it was already using a context object so this just adds caching.

I suggest reviewing each commit individually. Side by side diffs make the changes look more confusing than they really are. Netcore only because when sqlcommand is merged I expect the netcore versions to be used since they're generally better for perf.

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Patch coverage: 98.75% and project coverage change: +0.01 🎉

Comparison is base (3607fe2) 70.67% compared to head (2e1fd2a) 70.69%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2091      +/-   ##
==========================================
+ Coverage   70.67%   70.69%   +0.01%     
==========================================
  Files         306      306              
  Lines       61995    62071      +76     
==========================================
+ Hits        43816    43878      +62     
- Misses      18179    18193      +14     
Flag Coverage Δ
addons 92.88% <ø> (ø)
netcore 73.43% <98.75%> (+0.02%) ⬆️
netfx 69.33% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../Microsoft/Data/SqlClient/SqlInternalConnection.cs 72.77% <ø> (ø)
...netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs 84.07% <98.75%> (+0.39%) ⬆️

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@cheenamalhotra cheenamalhotra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a closer look sometime soon, but just sharing a few thoughts I had when I started looking into it.

Copy link
Contributor

@David-Engel David-Engel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely improves code readability. Thanks for the submission!

@David-Engel David-Engel merged commit 930133e into dotnet:main Aug 9, 2023
132 checks passed
@Wraith2 Wraith2 deleted the perf-asynccontextnonquery2 branch August 13, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants