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

Cache the getnode/gettoken classifiers retrieived from the extension manager. #73712

Merged
merged 6 commits into from
May 26, 2024

Conversation

ToddGrun
Copy link
Contributor

These showed up as ~6% of allocations in a find all references trace I'm looking at and it's trivial to cache these.

*** Previously ***
image

With my changes, these allocations are completely gone from the profile.

…manager.

These showed up as ~6% of allocations in a find all references trace I'm looking at.
@ToddGrun ToddGrun requested a review from a team as a code owner May 25, 2024 15:19
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 25, 2024
@@ -24,8 +25,17 @@ internal abstract class AbstractClassificationService(ISyntaxClassificationServi
{
private readonly ISyntaxClassificationService _syntaxClassificationService = syntaxClassificationService;

private static Func<SyntaxNode, ImmutableArray<Classifiers.ISyntaxClassifier>>? s_getNodeClassifiers;
private static Func<SyntaxToken, ImmutableArray<Classifiers.ISyntaxClassifier>>? s_getTokenClassifiers;
private static ExtensionClassifierInfo? s_cachedExtensionClassifierInfo;
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi May 25, 2024

Choose a reason for hiding this comment

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

alternatively. each classification service is lang specific. so don't cache these statically. cache as instance members.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ooh, I like that better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bummer, RemoteSemanticClassificationService accesses this method statically.

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 seems like a common enough code path, that it should also hit the optimization, and I don't want to cache these both statically and on the instances, so I think I'd prefer to keep it as is unless you see a nice way around this.

Copy link
Member

Choose a reason for hiding this comment

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

you can have RemoteSemanticClassificationService fetch the real service, not access it statically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the general idea works (I don't think RemoteSemanticClassificationService can access AbstractClassificationService, but I can just have the static method do the cast check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants