-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Parallel hub invocations #23535
Parallel hub invocations #23535
Conversation
I would prefer to see a bounded channel in the dispatch loop. |
Spoke to @BrennanConroy and we're going to do a bounded channel with N loops. |
*try |
BoundedChannel approach has some pros and cons: Pros:
Cons:
|
941ca57
to
b4274bc
Compare
7ec6328
to
fdfb9aa
Compare
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
{ | ||
internal static class SemaphoreSlimExtensions | ||
{ | ||
public static async Task<Task> RunAsync<TState>(this SemaphoreSlim semaphoreSlim, Func<TState, Task> callback, TState state) |
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 just realized this is going to allocate... Maybe we do a fast path like we do when we write a hub message
fdfb9aa
to
e78d587
Compare
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
return connection.ActiveInvocationLimit.RunAsync(state => | ||
{ | ||
var (dispatcher, descriptor, connection, invocationMessage) = state; | ||
return dispatcher.Invoke(descriptor, connection, invocationMessage, isStreamResponse: false, isStreamCall: false); |
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 the above call to Invoke ever throw?
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.
Not really. I think if you wrote a custom auth handler and threw in there it could throw. We could wrap that so it closes the connection with an error, but would prefer it in a different change.
} | ||
|
||
[Fact] | ||
public async Task StreamInvocationsDoNotBlockOtherInvocations() |
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.
Does this mean there's still no way to limit the number of concurrent streaming invocations per client?
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.
Yeah, we talked about this
Fixes #5351
HubConnectionContextOptions:
public int MaximumParallelInvocations { get; set; } = 1;
HubOptions:
public int MaxParallelInvocationsPerClient { get; set; }