Skip to content

Conversation

@DustinCampbell
Copy link
Member

Fixes #10306

The recent change to use an AsyncBatchingWorkQueue in ProjectConfigurationStateSynchronizer has resulted in a signficant regression. The syncrhonizer has somewhat subtle semantics that doesn't mesh well with AsyncBatchingWorkQueue. As part of rolling this change back, I've commented the code a bit more thoroughly to call out how it works and where the semantics are a bit flaky. Ultimately, I expect we'll be able to get rid of this once we stop writing project.razor.vs.bin files to disk.

Fixes dotnet#10306

The recent change to use an `AsyncBatchingWorkQueue` in
`ProjectConfigurationStateSynchronizer` has resulted in a signficant
regression. The syncrhonizer has somewhat subtle semantics that doesn't
mesh well with `AsyncBatchingWorkQueue`. As part of rolling this change
back, I've commented the code a bit more thoroughly to call out how it
works and where the semantics are a bit flaky. Ultimately, I expect
we'll be able to get rid of this once we stop writing
`project.razor.vs.bin` files to disk.
@DustinCampbell DustinCampbell requested a review from a team as a code owner April 24, 2024 17:57
@DustinCampbell DustinCampbell changed the title Don't use batching work queue in ProjectConfigurationStateSynchronizer Don't use batching work queue in ProjectConfigurationStateSynchronizer Apr 24, 2024
Copy link
Contributor

@alexgav alexgav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:


namespace Microsoft.AspNetCore.Razor.LanguageServer;

/// <summary>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this detailed comment! Is the issue before that async batching could cause problems when doing a lookup for projectkey to file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was that the project would get added early enough. Essentially, the async batching queue leveled the playing field so that everything happens in the same queue. However, the project add needs to happen before enqueueing an update. Otherwise, we get into bad behavior where a remove followed by an add (which happens when we delete and write a new file) causes files to be migrated to and from the misc project needlessly. @davidwengier wrote up a good explanation in #10306.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, I had a branch that kept the async batching queue, and just collapsed a Reset-then-Add to an Update, and it fixed the issue, so we could revisit this in future. At least we better understand the traps to look out for.

Also worth noting that even with the async batching queue, the integration tests pass. I noticed the issue due to some debug asserts in the MoveDocument method on RazorProjectService, and scouring the logs, but that was all caused by things happening between the reset and the add, and after the add the final state of things was all correct.

Copy link
Member Author

@DustinCampbell DustinCampbell Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I actually think things worked with the async batching queue. At least, it never failed for me when loading up OrchardCore. It just did a bunch of unnecessary work that I fully agree that we don't want to do. I'd prefer deleting this type altogether rather than spending too much more time on it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put up #10330 as an alternative to this. Curious for peoples thoughts.

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 love the additional comment context for understanding

@DustinCampbell
Copy link
Member Author

Closing this first attempt, which has been superseded by three others! 😄

@DustinCampbell DustinCampbell deleted the fix-configuration-state-synchronizer branch May 2, 2024 17:53
davidwengier added a commit that referenced this pull request May 2, 2024
…#10335)

Fixes #10306

This change takes a different approach than
#10308 and
#10330 and
#10332 because life was meant to be
interesting.

The original problem we were trying to solve is that when a Reset then
Add came in, we would migrate all of the documents out of the project,
then migrate them all back in again. The various solutions in the other
PRs you can read about at your leisure, this one takes a rather simple
approach:

1. Ignore everything but the most recent update for a specific project
2. If we need to update a project, but it doesn't exist, add it

In the long run we should remove `IRazorProjectService.AddProjectAsync`
entirely, and rename `IRazorProjectService.UpdateProjectAsync` to
`ResetProjectAsync`, but doing that now would just conflict with other
open PRs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProjectConfigurationStateSynchronizer is doing too much work

4 participants