-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add request concurrency information for processing by the RequestExec… #66727
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
…utionQueue. This replaces the MutatesServerState flag with a flag that indicates how the request should be treated. Specifically, I needed a mode where the request ensured that all prior pending requests had completed before processing.
Can you give an example of where/why you needed this? In reply to: 1419909945 In reply to: 1419909945 |
...atures/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestConcurrency.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...atures/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestConcurrency.cs
Outdated
Show resolved
Hide resolved
|
Yes, first a bit of context: dotnet/razor#8217 WebTools currently uses the O# WithContentModifiedSupport(false) behavior which ensures that all pending requests are cancelled and that the request is handled serially. WebTools needs this because our parse trees are updated during the didChange notification and our parse trees are immutable. We aren't resilient to operations operating our parse tree at a time when it is being modified. I'll add a comment to the code to better outline this use case. In reply to: 1419909945 |
|
The flags enum doesn't feel right here, to me. Two of the values control how a work item is processed (Parallel and RequiresCompletionBeforeFurtherQueueing), either nonblocking or blocking, and one of them controls the queue state before the work item is processed, either empty or dont care, except there is no explicit option for don't care. In reply to: 1419935504 |
|
I agree, it does feel a little odd. Any suggestions for something better? In reply to: 1419935504 |
|
Do you expect to actually need to set RequiresPreviousQueueItemsCancelled on an individual handler, but not on others? Feels like a boolean property of the queue itself. In reply to: 1419988252 |
|
Yes, webtools needs this set on the didChange, didOpen, didClose handlers, but not any others. In reply to: 1419988252 |
|
But aren't they the only ones that are mutating? They are in roslyn and razor at least In reply to: 1419997630 |
|
I think I understand. You are saying that we could add a virtual bool on RequestExecutionQueue that indicates whether serial behavior requires clearing out the queue, correct? In reply to: 1419997630 |
davidwengier
left a comment
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.
Makes sense to me
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
ryanbrandenburg
left a comment
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.
Other than the one comment about using the dictionary in the base-case this looks great.
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...alStudio/Xaml/Impl/Implementation/LanguageServer/Handler/OnTypeRename/OnTypeRenameHandler.cs
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
| var context = await work.CreateRequestContextAsync(cancellationToken).ConfigureAwait(false); | ||
| if (work.MutatesServerState) | ||
| { | ||
| if (CancelInProgressWorkUponMutatingRequest) |
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 add some unit tests that verify that the queue behaves as you expect? e.g. verify previous work completes/cancelled before the mutating item starts, verify queue cancellation still functions correctly with this option, etc.
we have some existing tests here - https://sourceroslyn.io/#Microsoft.CommonLanguageServerProtocol.Framework.UnitTests/RequestExecutionQueueTests.cs,8166c4c6b96c4379
and https://sourceroslyn.io/#Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests/Ordering/RequestOrderingTests.cs,20
Remove an IsCancellationRequested check. Throw some InvalidOperationExceptions based on unreachable conditions.
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
|
|
||
| if (!concurrentlyExecutingTasks.TryAdd(currentWorkTask, currentWorkCts)) | ||
| { | ||
| throw new InvalidOperationException($"unable to add {currentWorkTask} into {concurrentlyExecutingTasks}"); |
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.
Did you mean to use nameof() for those locals? Otherwise I think you're just going to get type names, right?
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.
bah, yes!
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.
also, just do Contract.ThrowIfFalse(...TryAdd(...)); :)
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.
The Contract class isn't available in this project, from what I've seen, thus all the long winded throwing of InvalidOperationExceptions.
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.
- Ughhhhhhhhhhhhhhhhhhhhhh
- Can we not just source-link it in?
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.
At least for the nullability ones, aren't they required to be in a certain namespace for them to work?
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.
what nullability types are you referring to?
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.
NotNullAttribute for example, referenced here
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.
looks like you pull in C:\github\roslyn\src\Compilers\Core\Portable\InternalUtilities\NullableAttributes.cs for that. Which does nothing if you're on netcore (since runtime provides it).
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 think I'm confusing System.Runtime.CompilerServices.NullableAttribute with the one linked above.
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
...res/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs
Outdated
Show resolved
Hide resolved
…, using NoThrowAwaitableInternal, and slightly different exception handling
|
Abandoning in favor of Ryan's derivation of this, as his has the tests (and the dependency removal that I provided) |
…utionQueue.
This replaces the MutatesServerState flag with a flag that indicates how the request should be treated. Specifically, I needed a mode where the request ensured that all prior pending requests had completed before processing.