Skip to content

Ignore updates with no changes for csharp files #8162

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

Merged
merged 3 commits into from
Apr 10, 2025

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Apr 9, 2025

Before #7826 razor would use textdocument/{open, changed, closed} for csharp changes. That would mean that if the text didn't actually change vs code wouldn't notify roslyn. After that change the notification is handled for closed files by the razorDocumentManager. This causes a loop where csharp generated -> workspace changed for generated csharp -> workspace listeners notifies change -> generation is queued -> change is reported -> workspace changed for csharp -> ....

This is a quicker fix to hopefully unblock while I investigate a more comprehensive fix on the razor side

@ryzngard ryzngard requested a review from a team as a code owner April 9, 2025 22:06
Copy link
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

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

Say verbose logging was enabled. How many of these requests are we talking about?

@ryzngard
Copy link
Contributor Author

ryzngard commented Apr 9, 2025

Say verbose logging was enabled. How many of these requests are we talking about?

#8152 (comment)

~9x

@JoeRobich
Copy link
Member

~9x

Will definitely notice that in the log

@@ -189,7 +190,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
}
}

this.notifyDocumentChange(document, RazorDocumentChangeKind.closed);
this.notifyDocumentChange(document, RazorDocumentChangeKind.closed, []);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

intentionally leaving these empty. For open/close/add/remove the changes are irrelevant.

@@ -40,7 +40,7 @@ export class DynamicFileInfoHandler {
}
);
this.documentManager.onChange(async (e) => {
if (e.kind == RazorDocumentChangeKind.csharpChanged && !e.document.isOpen) {
if (e.kind == RazorDocumentChangeKind.csharpChanged && !e.document.isOpen && e.changes.length > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the change that reduces updates. Even if our version is bumped as long as the csharp text didn't change no point in sending a notification to Roslyn

@@ -40,7 +40,7 @@ export class DynamicFileInfoHandler {
}
);
this.documentManager.onChange(async (e) => {
if (e.kind == RazorDocumentChangeKind.csharpChanged && !e.document.isOpen) {
if (e.kind == RazorDocumentChangeKind.csharpChanged && !e.document.isOpen && e.changes.length > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for walking through this with me offline! Since it's perf sensitive, consider adding a comment here to describe the conditions that we don't want to update the dynamic file info.

Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

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

Fixes the issue on aspire for me

@ryzngard ryzngard enabled auto-merge (squash) April 10, 2025 00:34
@ryzngard ryzngard merged commit 803d496 into dotnet:main Apr 10, 2025
24 checks passed
@dibarbet
Copy link
Member

/backport to release

Copy link
Contributor

Started backporting to release: https://github.com/dotnet/vscode-csharp/actions/runs/14393236954

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.

4 participants