-
Notifications
You must be signed in to change notification settings - Fork 286
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
Add scaffolding for pool throttling #2667
Add scaffolding for pool throttling #2667
Conversation
…n connection string options.
} | ||
} | ||
|
||
private bool IsBlockingPeriodEnabled() |
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.
carried over verbatim from DbConnectionPool
@@ -40,14 +36,10 @@ protected override SqlConnectionX CreateDbConnection() | |||
|
|||
internal SqlDataSource( | |||
SqlConnectionStringBuilder connectionStringBuilder, | |||
SqlCredential credential, | |||
RemoteCertificateValidationCallback userCertificateValidationCallback, |
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.
removing these for now until we fully implement additional auth pathways
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/PoolingDataSource.cs
Outdated
Show resolved
Hide resolved
....Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/ConcurrencyRateLimiter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/SqlDataSourceBuilder.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/IRateLimiter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/SqlDataSourceBuilder.cs
Outdated
Show resolved
Hide resolved
...ta.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/BlockingPeriodRateLimiter.cs
Outdated
Show resolved
Hide resolved
....Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/ConcurrencyRateLimiter.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/PoolingDataSource.cs
Outdated
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.
Mostly nit changes, but let me get back to you about the delegate stuff. I'm not convinced we can't do that with less overhead.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/PoolingDataSource.cs
Outdated
Show resolved
Hide resolved
...Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/AsyncFlagFunc.cs
Outdated
Show resolved
Hide resolved
...ta.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/BlockingPeriodRateLimiter.cs
Outdated
Show resolved
Hide resolved
....Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/ConcurrencyRateLimiter.cs
Outdated
Show resolved
Hide resolved
....Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/ConcurrencyRateLimiter.cs
Outdated
Show resolved
Hide resolved
....Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/PassthroughRateLimiter.cs
Outdated
Show resolved
Hide resolved
....Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/PassthroughRateLimiter.cs
Outdated
Show resolved
Hide resolved
...crosoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/RateLimiterBase.cs
Outdated
Show resolved
Hide resolved
/// <param name="async">Whether this method should run asynchronously.</param> | ||
/// <param name="cancellationToken">Cancels outstanding requests.</param> | ||
/// <returns>Returns the result of the callback or the next rate limiter.</returns> | ||
internal abstract ValueTask<TResult> Execute<State, TResult>(AsyncFlagFunc<State, ValueTask<TResult>> callback, State state, bool async, CancellationToken cancellationToken = default); |
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'm wondering - using a delegate here might introduce some overhead we can avoid. I'm going to try a quick benchmark test to verify what I'm thinking, let me get back to 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.
Based on @benrr101 's benchmarking, delegates are the slowest (compared to lambdas and concrete functions). I'll give this setup some thought as I implement the logic of the callback to see if this setup still makes sense or if we can switch to something more performant while still preserving the intent of the interface we expose to the rate limiters.
...Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/AsyncFlagFunc.cs
Outdated
Show resolved
Hide resolved
...ta.SqlClient/netcore/src/Microsoft/Data/SqlClientX/RateLimiters/BlockingPeriodRateLimiter.cs
Outdated
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.
Sounds pretty good to me 👍
This adds a mechanism for throttling enforcement within the connection pool. Basic passthrough and concurrency limiters are included. Focusing on the high throughput case (no rate limit), so I will add a backlog work item to implement the pool blocking period rate limiter.