Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Perf improvements in Current MDS code #2672

saurabh500 started this conversation in General
Discussion options

Starting this thread to point out some areas where we can benefit from perf improvement.

I will start a comment for every code spot, and we can discuss on those threads individually.

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

https://github.com/dotnet/SqlClient/blob/main/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs#L7524-L7545

The write string tries to write to the output buffer directly if there is space available.
This is used for sending large XML files also.

This means that we will always allocate a buffer if the size of outgoing string is > packet size.

You must be logged in to vote
2 replies
Comment options

saurabh500 Jul 13, 2024
Maintainer Author

I haven't benchmarked this yet.
However for XML chunked writing is supported.
using (ConstrainedTextWriter writer = new ConstrainedTextWriter(new StreamWriter(new TdsOutputStream(this, stateObj, preambleToSkip), encoding), size))

Comment options

saurabh500 Jul 13, 2024
Maintainer Author

The text writer can write chunked text, and adheres to PLP chunking in TDS protocol. However that is not the necessary solution. If we could use the Unicode encoded string to write to the output buffer directly in chunks rather than allocating the full buffer, that would be a simpler and less disruptive change. However I haven't explored the APIs enough to conclude that this is a viable path or not.

We will definitely need something similar for JSON as well. The JSON string will be sent as UTF8. So pre-calculating the length is not going to work, since UTF8 has varying length characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /