-
Notifications
You must be signed in to change notification settings - Fork 196
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
Replace BatchingWorkQueue
with AsyncBatchingWorkQueue
from Roslyn
#10140
Conversation
0bdcd7e
to
1ef11e6
Compare
BatchingWorkQueue
with AsyncBatchingWorkQueue
from RoslynBatchingWorkQueue
with AsyncBatchingWorkQueue
from Roslyn
ea8db69
to
21dbfae
Compare
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
c1f8f49
to
2814950
Compare
...azor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs
Outdated
Show resolved
Hide resolved
...zor/src/Microsoft.VisualStudio.LanguageServices.Razor/WorkspaceProjectStateChangeDetector.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Threading/CancellationSeries.cs
Outdated
Show resolved
Hide resolved
src/Razor/src/Microsoft.AspNetCore.Razor.ProjectEngineHost/Threading/CancellationSeries.cs
Outdated
Show resolved
Hide resolved
...azor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs
Outdated
Show resolved
Hide resolved
...azor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs
Show resolved
Hide resolved
2814950
to
d49ff1e
Compare
Approval was unintentional added to draft PR
...azor/src/Microsoft.AspNetCore.Razor.LanguageServer/WorkspaceSemanticTokensRefreshNotifier.cs
Outdated
Show resolved
Hide resolved
Roslyn's `AsyncBatchingWorkQueue` is a battle-hardened utility that provides a robust mechanism to do work in batches without blocking.
…ations `WorkspaceSemanticTokensRefreshNotifier` (previously `WorkspaceSemanticTokensRefreshPublisher`) uses a `BatchingWorkQueue` for debouncing, even though it isn't actually batching work. I've replaced this with much simpler code that just tracks a `Task` generated with `Task.Delay(...)`.
Remove invalid link from comment and make code style consistent.
@CyrusNajmabadi, @davidwengier, @jjonescz: I've made further changes to pull the "most recent item" de-duping out of |
src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared.Test/ImmutableArrayExtensionsTests.cs
Outdated
Show resolved
Hide resolved
#if !NETSTANDARD2_0 | ||
var uniqueItems = new HashSet<T>(capacity: source.Length, comparer); | ||
#else | ||
var uniqueItems = new HashSet<T>(comparer); | ||
#endif |
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/Should this be pooled?
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.
Unfortunately, no. It can't because of the comparer. Like Dictionary<TKey, TValue>
, there's no way to set a HashSet<T>
comparer other than in the constructor.
Still LGTM |
src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared.Test/ImmutableArrayExtensionsTests.cs
Outdated
Show resolved
Hide resolved
src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs
Outdated
Show resolved
Hide resolved
src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs
Outdated
Show resolved
Hide resolved
src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/ImmutableArrayExtensions.cs
Show resolved
Hide resolved
Heads up that there might be an RPS regression from this Known good: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/538963 |
Possibly, but I'm not sure. There were similar RPS regressions in our 17.10p3 payload that have been fixed in the |
The fixes have merged to main |
@RikkiGibson: Now that main has the release/dev17.10 fixes, is there an updated PR we can track? |
Latest main insertion is showing fewer assembly loads but still elevated from baseline https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/539887 |
I think that's going to require further investigation. Could you file an issue, start a mail thread, or raise this in Teams? It feels like the right eyes aren't going to see this on a closed PR. I'll start digging in though. |
Started the conversation on the infraswat side. Thanks! |
OK. I'm not on infraswat and probably won't see that. However, I suspect that @phil-allen-msft is. Just know that I'm actively investigating and working on a fix. |
Fixes #10158
I recommend reviewing commit-by-commit.
Razor has had a
BatchingWorkQueue
for a long while that has dubious semantics. It is used by three features:OpenDocumentGenerator
- Listens for document updates, computes generated output for each, and notifies listeners when a document has been processed.WorkspaceSemanticTokensRefreshPublisher
- Called in the server to send the clientsemanticTokens/refresh
notifications. This really sort of abusesBatchingWorkQueue
just for debouncing and only send notifications every 250 milliseconds.WorkspaceProjectStateChangeDetector
- Listens for Roslyn workspace and Razor project manager changes and calls intoIProjectWorkspaceStateGenerator.Update(...)
when a change occurs.This change fully replaces
BatchingWorkQueue
with a copy of Roslyn'sAsyncBatchingWorkQueue
, which has consistent semantics and has been battle-hardened for years. I've updatedOpenDocumentGenerator
andWorkspaceProjectStateChangeDetector
above to useAsyncBatchingWorkQueue
. ForWorkspaceSemanticTokensRefreshPublisher
(nowWorkspaceSemanticTokensRefreshNotifier
), I've removed theBatchingWorkQueue
altogether and replaced it with simpler logic that debounces and callsTask.Delay(...)
.Many thanks to @CyrusNajmabadi for his help with
AsyncBatchingWorkQueue
.@dotnet/razor-compiler: The only relevant compiler changes are in shared code.