-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Cache the getnode/gettoken classifiers retrieived from the extension manager. #73712
Conversation
…manager. These showed up as ~6% of allocations in a find all references trace I'm looking at.
@@ -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; |
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.
alternatively. each classification service is lang specific. so don't cache these statically. cache as instance members.
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.
ooh, I like that better
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.
Bummer, RemoteSemanticClassificationService accesses this method statically.
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.
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.
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.
you can have RemoteSemanticClassificationService fetch the real service, not access it statically.
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.
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.
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 ***
With my changes, these allocations are completely gone from the profile.