-
Notifications
You must be signed in to change notification settings - Fork 311
Improve async string perf and fix reading chars with initial offset. #3377
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
Conversation
…decrease memcopy and gc time spent
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
/cc @Tornhoof, @AlexanderKot this should fix your issues. @dotnet/sqlclientdevteam can I get a CI kick? I'd really really like to get this in to preview 2 because it fixes all the known issues with async continue. |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3377 +/- ##
==========================================
- Coverage 67.04% 59.71% -7.33%
==========================================
Files 300 293 -7
Lines 65376 65308 -68
==========================================
- Hits 43831 39000 -4831
- Misses 21545 26308 +4763
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR targets performance improvements in asynchronous string processing and corrects an issue with reading characters using an initial offset.
- Added a new sequential character reading test ("CanGetCharsSequentially") to verify correct behavior.
- Introduced helper methods in tests to use pooled buffers, ensuring buffers are resized appropriately.
- Updated buffer management logic in TdsParser (both netfx and netcore) to use the correct offset and to improve buffer reallocation efficiency.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs | Adds a new test and helper method for sequential character reading using pooled buffers. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs | Introduces a GetPacketSize() method and a property to calculate the current packet index. |
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs | Adjusts buffer sizing logic and offset handling to improve performance and correctness. |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs | Mirrors changes in netfx for improved buffer management and offset accumulation. |
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/DataReaderTest/DataReaderTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs
Outdated
Show resolved
Hide resolved
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say I know much about the internals here, so I appreciate the callouts on what changes are being made. However, I'm not understanding what the _longlen changes are really doing. Please take a look at my comments and I'll approve if you can explain it without code changes :)
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
Show resolved
Hide resolved
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
@benrr101 this one needs an updated review from you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes!
* Revert 1af7327 * Revert "Fix TryReadPlpBytes throws ArgumentException (#3470) (#3474)" This reverts commit 0a55896. * Revert 44762d9 * Revert "Improve async string perf and fix reading chars with initial offset. (#3377)" This reverts commit 05df554. * Revert "Refine handling of moving between replay and continue states (#3337)" This reverts commit 265f522. * Revert "Fix SqlCached buffer async read with continue edge case. (#3329)" This reverts commit c3857b1. * Revert "Add `async` snapshot continue capability for multipacket fields (#3161)" This reverts commit 33364e7. * Revert "Add partial packet detection and fixup (#2714)" This reverts commit 8d5e4f2. * Remove methods previously moved to common file. * Supply byte buffer to vector read. * Minor compilation fixes that were missed in the reverts. * Remove partial packet context switch helpers. * Remove accidental duplication of SqlDataReader * Revert len change * Undo buff rental in netfx to simplify 6.0 diff. * Fix missed rented buff code. --------- Co-authored-by: Cheena Malhotra <[email protected]>
Description
For performance related changes see background information in #3274 (comment) and the preceeding conversation. Reading a string in async mode was being slower than expected so I investigated. I will annotate each change with an explanation.
Issues
fixes #3331
fixes #3274
Testing
Tests have been added which cover both issues that are being fixed.