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

replace read async with read of SqlReader for perf #904

Merged
merged 96 commits into from
Nov 1, 2023

Conversation

MaddyDev
Copy link
Contributor

@MaddyDev MaddyDev commented Aug 9, 2023

Fixes #903

To preemptively address the below issues, we followed the fix made in sqltools service (microsoft/sqltoolsservice#2161)

dotnet/SqlClient#593
dotnet/SqlClient#44

Charles-Gagnon and others added 30 commits March 15, 2023 09:14
[Trigger] Add release branch to PR build triggers (#734)
* add support for jobject and js, ps, python samples

* use utils JsonSerializeObject + comment

* Update src/TriggerBinding/SqlTriggerBindingProvider.cs

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* fix unit test + pylint

---------

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
* Add link to privacy statement

* Add privacy link to output message

* add to output message

* Fix typos

(cherry picked from commit a9565f7)
* add sqltrigger attribute

* add SqlChange type

* enable oop test

* add check

* fix the null reference

* use GetLogger
[Trigger] Add Privacy Statement to README and telemetry message (#751)
* enable debug logging for ps and python samples

* enable debug logs for js samples
* add js, py, ps ProductsTriggerWithValidation test

* fix test + missing file
* Further clarifications to trigger retry docs

* Update description
* add more oop test samples

* update logger
[Trigger] Filter out more default telemetry properties
# Conflicts:
#	README.md
#	builds/azure-pipelines/build-release.yml
#	src/Telemetry/Telemetry.cs
* add SQLTrigger annotation to java library

* remove default values

* use enum for commandtype
* add js, py, ps ProductsTriggerWithValidation test

* fix test + missing file

* add tests

* remove extra comments + powershell compress

* update comment
[Trigger] Merge latest from main
* Refactor SqlTriggerListener scaling to SqlTriggerMetricsProvider and SqlTriggerScaleMonitor

* Create SqlTriggerTargetScaler

* Refactor unit tests

* Refactor to include common queries for scaling and listener class to SqlTriggerUtils

* Add doc comments for scaling classes

* Update src/TriggerBinding/SqlTriggerTargetScaler.cs

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* Fix log statement

* Update WebJobs package

* Update nuget.config

* Address review comments

* Address review comments pt2

* Update src/TriggerBinding/SqlTriggerTargetScaler.cs

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* Address comments, test failures

* Fix packages lock file

* Fix error message

* Address comments and test failures

* Apply suggestions from code review

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>

* Change in documentation

* Fix log level

---------

Co-authored-by: Charles Gagnon <chgagnon@microsoft.com>
[Trigger] Merge latest from main
@Charles-Gagnon
Copy link
Contributor

@cheenamalhotra This look good to you?

@@ -112,7 +112,7 @@ private async Task<bool> GetNextRowAsync()
this._reader = await command.ExecuteReaderAsync();
Copy link
Member

Choose a reason for hiding this comment

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

Since ExecuteReaderAsync has issues with cancellation - I would recommend changing that to ExecuteReader too. Do you plan to do that separately?

Copy link
Contributor

Choose a reason for hiding this comment

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

That goes for any Async calls from SqlClient, right? @MaddyDev Make sure you're doing a search all for anything with "Async" in its name so we aren't missing any others.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MaddyDev You didn't update this one yet, is that on purpose?

@@ -599,7 +599,7 @@ public static async Task<TableInformation> RetrieveTableInformationAsync(SqlConn
{
string getPrimaryKeysQuery = GetPrimaryKeysQuery(table);
var cmd = new SqlCommand(getPrimaryKeysQuery, sqlConnection);
using (SqlDataReader rdr = await cmd.ExecuteReaderAsyncWithLogging(logger, CancellationToken.None))
using (SqlDataReader rdr = cmd.ExecuteReaderWithLogging(logger))
{
while (await rdr.ReadAsync())
Copy link
Contributor

Choose a reason for hiding this comment

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

What about this ReadAsync (and the one above)?

{
TelemetryInstance.TrackEvent(TelemetryEventName.TableInfoCacheMiss, props);
// set the columnNames for supporting T as JObject since it doesn't have columns in the member info.
tableInfo = await TableInformation.RetrieveTableInformationAsync(connection, fullTableName, this._logger, GetColumnNamesFromItem(rows.First()), this._serverProperties);
tableInfo = TableInformation.RetrieveTableInformationAsync(connection, fullTableName, this._logger, GetColumnNamesFromItem(rows.First()), this._serverProperties);
Copy link
Contributor

@lucyzhang929 lucyzhang929 Aug 11, 2023

Choose a reason for hiding this comment

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

Should we also remove the Async from the method names? (RetrieveTableInformation)

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 - for any methods that no longer have await in them we should clean those up

@chlafreniere
Copy link
Contributor

How will we measure impact after this change?

@Charles-Gagnon
Copy link
Contributor

That would seem to fit nicely into the work we already have planned for perf baselines. @MaddyDev maybe you hold off on getting this in for now (since it's not actively blocking anyone AFAIK) and instead focus on getting the perf stuff figured out first so we can both test the usefulness of that along with validating that this is actually making an improvement?

@MaddyDev MaddyDev marked this pull request as draft August 14, 2023 07:44
@GeeSuth
Copy link

GeeSuth commented Sep 18, 2023

it's that mean the #903 will not fixed?

@MaddyDev MaddyDev changed the base branch from release/trigger to main September 22, 2023 18:12
@MaddyDev MaddyDev marked this pull request as ready for review October 6, 2023 17:05
@MaddyDev MaddyDev merged commit cfb4b85 into main Nov 1, 2023
3 checks passed
@MaddyDev MaddyDev deleted the maddy/replaceReadAsync branch November 1, 2023 19:12
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.

Investigate use of SqlClient ReadAsync
8 participants