-
Notifications
You must be signed in to change notification settings - Fork 299
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
Use an IBufferWriter<byte> to write the outgoing SSPI blob #2452
base: main
Are you sure you want to change the base?
Conversation
This change removes the need to pre-allocate anything for the outgoing blobs of SSPI generation. As part of this: - An internal implementation of ArrayBufferWriter is added for platforms that do not support it - SqlObjectPool is imbued with the ability to create/reset pooled objects - TdsParser/TdsLogin is updated to use pooled ArrayBufferWriter instances to generate SSPI blobs - Native methods are updated to take in Span/* for writeable byte[] - SSPIContextProvider signature is updated to take IBufferWriter
@David-Engel can I get a review on this next step in the SSPI journey? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2452 +/- ##
==========================================
- Coverage 72.73% 66.10% -6.64%
==========================================
Files 283 278 -5
Lines 58997 58712 -285
==========================================
- Hits 42910 38810 -4100
- Misses 16087 19902 +3815
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@David-Engel ping |
I ran our internal Kerberos test pipeline against this PR and all tests passed. |
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSSPIContextProvider.cs
Outdated
Show resolved
Hide resolved
@David-Engel can you run this on the kerberos suite again? |
@David-Engel something is up with the merges so let me get those fixed before you do the kerberos runs |
@David-Engel I'm getting sporadic errors that don't seem to always repro: https://sqlclientdrivers.visualstudio.com/public/_build/results?buildId=96359&view=logs&j=b14281d2-3365-502e-c6c8-e9e46d660715&t=a67f9feb-8bad-50ac-92c7-d62292e3e6fb&l=63 Have you seen these or are they related to my pr? |
src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ArrayBufferWriter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ArrayBufferWriter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ArrayBufferWriter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParser.cs
Outdated
Show resolved
Hide resolved
@@ -8,6 +8,8 @@ namespace Microsoft.Data.SqlClient | |||
{ | |||
internal partial class TdsParser | |||
{ | |||
private static readonly SqlObjectPool<ArrayBufferWriter<byte>> _writers = new(20, () => new(), a => a.Clear()); |
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.
No complain here only I'm curious about the constant 20 pooled objects here!
cc @David-Engel
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.
honestly I don't remember where the 20 came from. Seemed reasonable I think at the time, but I'm not really aware of how many concurrent calls to it are called in a given connection
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 dug into the SqlObjectPool logic because I was curious, so thought I would share in case anyone else was wondering. 20 here isn't a limit on parallelism or anything. It's just the maximum number that will be cached. Parallel Rents from the pool above 20 will simply get a new object. I agree that 20 should be plenty for the majority of scenarios.
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.
Can you please add a comment in the code indicating the reasoning for 20?
@cheenamalhotra can you trigger a build again? will it automatically build if I switch it away from draft? |
@David-Engel can you kick off the build for this? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@David-Engel can you run the tests again? |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@David-Engel @cheenamalhotra This PR is passing all tests and ready for review. Thanks! |
@@ -842,145 +842,6 @@ internal void WriteByte(byte b) | |||
_outBuff[_outBytesUsed++] = b; | |||
} | |||
|
|||
internal Task WriteByteSpan(ReadOnlySpan<byte> span, bool canAccumulate = true, TaskCompletionSource<object> completion = null) |
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.
Note: this is removed in the netcore/netfx specific files, and the netcore implementation is now in the shared TdsParserStateObject class
74f7138
to
c43f86f
Compare
c43f86f
to
7b7ee36
Compare
@David-Engel these build failures appear to be occurring on main as well. Can I get a review here? |
@@ -8,6 +8,8 @@ namespace Microsoft.Data.SqlClient | |||
{ | |||
internal partial class TdsParser | |||
{ | |||
private static readonly SqlObjectPool<ArrayBufferWriter<byte>> _writers = new(20, () => new(), a => a.Clear()); |
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 dug into the SqlObjectPool logic because I was curious, so thought I would share in case anyone else was wondering. 20 here isn't a limit on parallelism or anything. It's just the maximum number that will be cached. Parallel Rents from the pool above 20 will simply get a new object. I agree that 20 should be plenty for the majority of scenarios.
Looks like the "restore" step is failing for a bunch of the tests |
Yup. It's not your PR. It seems like a new underlying tooling bug on ARM64. We are investigating. |
} | ||
try | ||
{ | ||
TdsParser.ReliabilitySection.Assert("unreliable call to WriteByteArray"); // you need to setup for a thread abort somewhere before you call this method |
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.
@@ -8,6 +8,8 @@ namespace Microsoft.Data.SqlClient | |||
{ | |||
internal partial class TdsParser | |||
{ | |||
private static readonly SqlObjectPool<ArrayBufferWriter<byte>> _writers = new(20, () => new(), a => a.Clear()); |
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.
Can you please add a comment in the code indicating the reasoning for 20?
This change removes the need to pre-allocate anything for the outgoing blobs of SSPI generation. As part of this:
Part of #2253