-
Notifications
You must be signed in to change notification settings - Fork 215
Modify TagHelperCollector to use it's per assembly cache more often #12313
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
base: main
Are you sure you want to change the base?
Modify TagHelperCollector to use it's per assembly cache more often #12313
Conversation
The caching done in TagHelperCollector.Collect(TagHelperDescriptorProviderContext, CancellationToken) was only being done on the reference assemblies. This PR also adds that caching for the target or compilation assembly. Test insertion: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/678059 Results from the speedometer tests in the above insertion looked good. The table below shows the average CPU/Allocs in the CA process for the CompletionInCohosting test under the TagHelperCollector.Collect method. | Version| CPU (ms) | CPU (%) | Allocs MB | Allocs (%) | |---|---|---|---|---| | Original| 4600 | 7.7 | 291 | 12.3 | | New | 2965 | 5.4 | 110 | 5.9 |
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.
FWIW, I'm surprised that we're being called for the same Compilation.Assembly
more than once. I would have expected the source generator to use its own cached results if the Compilation.Assembly
didn't change.
I'd love to know what this looks like for a modern Blazor app with lots of components, such as MudBlazor. Do our Speedometer tests still just measure legacy Razor? If so, we're kind of blind to what most users are doing with modern .NET, which should be much more performance intensive.
Also, could you do toolset run for this? Whenever we tweak tag helper discovery, it's a good to run that to spot potential regressions.
I (and the perf tests) definitely see this hitting many times for the same assembly, @chsienki for whether that's expected.
Yes, but I do have a PR that I've created to add MudBlazor tests.
Yes, but this would be a first for me, so I would appreciate if you could point me to some docs on how to do this. In reply to: 3324563145 |
🎉 At the very least, it might be useful to get some before and after numbers for MudBlazor locally. I'm expecting that the savings will be more dramatic, but I'm not sure. |
Actually, I think I showed you in person instead of writing something up. It's super easy. You can use the same branch that you pushed to run a test insertion.
|
Looks like both the toolset run you did and the one I kicked off passed. Thanks! |
Given Dustin's comment, and because I don't understand the mechanisms of assembly symbols and the caching of them, I'm wary of this without some specific tests. None of the speedometer or RPS tests change the tag helpers in a compilation, and it seems like that is the big risk here. Correct me if I'm wrong, but if we get a bad cache hit, that presumably manifests as "I add a new Razor file and it doesn't appear in completion/has squiggles until VS is restarted", which is pretty egregious and I'm not sure how many of even our own testing covers that (which is probably a big gap we should address), but certainly nothing in RPS, Speedometer or the toolset does. Also we just had a report of something very similar to that hypothetical, in #12306, across a project reference boundary. Maybe source assembly symbols in a CWT aren't behaving like we think they should? I had a look through history a bit and it doesn't look like any of the PRs that touched it have added scenario specific tests. Maybe they already exist though? Do we have any tests for the CWT that manipulate a compilation over time? |
The caching done in TagHelperCollector.Collect(TagHelperDescriptorProviderContext, CancellationToken) was only being done on the reference assemblies. This PR also adds that caching for the target or compilation assembly.
Test insertion: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/678059
Results from the speedometer tests in the above insertion looked good. The table below shows the average CPU/Allocs in the CA process for the CompletionInCohosting test under the TagHelperCollector.Collect method.