Skip to content
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

Reduce update frequency from RazorWorkspaceListener #10756

Closed
wants to merge 15 commits into from

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Aug 16, 2024

This is the start of making it so the information sent over the named pipe is less noisy. The aim is to detect if any changes need to be synchronized to razor. It still calculates and serializes the full project information; the aim is to reduce that in a later PR.

@ryzngard ryzngard marked this pull request as ready for review August 19, 2024 22:58
@ryzngard ryzngard requested a review from a team as a code owner August 19, 2024 22:58
Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

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

I took a pass through and added some comments. Beyond the minor feedback, I strongly suggest not relying on GetHashCode(). Instead, use our Checksum infrastructure to produce stronger identity for the cache.

return (false, null);
}

if (entry.DocumentsHash != documents.GetHashCode())
Copy link
Member

Choose a reason for hiding this comment

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

This won't do what you want. Instead, it'll likely return true almost every time. RazorProjectInfoHelpers.GetDocumts() returns a new ImmutableArray<DocumentSnapshotHandle> each time it's called, and ImmutableArray<T>.GetHashCode() isn't computed from the contents; it just passes the reference to the underlying array.

To address this, please use Microsoft.AspNetCore.Razor.Utilities.Checksum and build up a checksum.

Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

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

I didn't look too closely at anything after my last comment, because it seemed like Dustin covered it. Definitely +1 to the GetHashCode() usage, it definitely reads as potentially incorrect (eg, even though RazorConfiguration defines an override, is it handling its Extensions property correctly??). If it isn't, then comments confirming that would be appreciated.

var csharpLanguageVersion = (project.ParseOptions as CSharpParseOptions)?.LanguageVersion ?? LanguageVersion.Default;
CachedTagHelperResolver.DeltaResult? delta = null;

var configuration = RazorProjectInfoHelpers.ComputeRazorConfigurationOptions(project.AnalyzerOptions.AnalyzerConfigOptionsProvider, out var rootNamespace);
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the null check, bool Try...(out, out) could also be appropriate

@ryzngard
Copy link
Contributor Author

Converting to draft while I think on this more

@ryzngard ryzngard marked this pull request as draft August 27, 2024 23:28
ryzngard added a commit to ryzngard/razor that referenced this pull request Aug 29, 2024
@ryzngard ryzngard closed this Sep 3, 2024
@ryzngard
Copy link
Contributor Author

ryzngard commented Sep 3, 2024

Replaced with #10813

@ryzngard ryzngard deleted the reduce_namedpipe_chatter branch September 3, 2024 18:33
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.

3 participants