Skip to content

Ignore updates with no changes for csharp files#8162

Merged
ryzngard merged 3 commits intodotnet:mainfrom
ryzngard:ignore_empty_updates
Apr 10, 2025
Merged

Ignore updates with no changes for csharp files#8162
ryzngard merged 3 commits intodotnet:mainfrom
ryzngard:ignore_empty_updates

Conversation

@ryzngard
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

~9x

Will definitely notice that in the log

}

this.notifyDocumentChange(document, RazorDocumentChangeKind.closed);
this.notifyDocumentChange(document, RazorDocumentChangeKind.closed, []);
Copy link
Copy Markdown
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.

);
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
Copy Markdown
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

);
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

/backport to release

@github-actions
Copy link
Copy Markdown
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