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

Ensure we only ask for a symbol's documentation comment once #68452

Conversation

jasonmalinowski
Copy link
Member

Right now computing hover information is a fairly expensive portion of an LSIF dump. One small hotspot was we were fetching documentation comment information at least twice: once for the documentation itself and once for computing the exception info. This ensures we fetch it just once per generation.

This also generally cleans up the AbstractSymbolDescriptionBuilder:

  1. Duplicate local functions for returns/value is unified.
  2. Removes a bunch of specific logic in the builder which supported finding the correct documentation in favor of the helper we already had.

To support the second one, I added some methods to DocumentationComment to return a DocumentationComment with the contents of a tag as the summary text for a specific parameter; this allows everything else to be able to operate as if that's a regular summary tag and removes some special cases in the code.

This by itself isn't the hugest speedup (maybe a couple of percent) but generally makes the code easier to follow and easier to see where the remaining expensive bits are in traces.

This also removes the IStructuralTypeDisplayService we were passing
around when we already had (or coud have) language services available.
Right now computing hover information is a fairly expensive portion
of an LSIF dump. One small hotspot was we were fetching documentation
comment information at least twice: once for the documentation itself
and once for computing the exception info. This ensures we fetch
it just once per generation.

This also generally cleans up the AbstractSymbolDescriptionBuilder:

1. Duplicate local functions for returns/value is unified.
2. Removes a bunch of specific logic in the builder which supported
   finding the correct documentation in favor of the helper we
   already had.

To support the second one, I added some methods to DocumentationComment
to return a DocumentationComment with the contents of a <param> tag
as the summary text for a specific parameter; this allows everything
else to be able to operate as if that's a regular summary tag and
removes some special cases in the code.
@jasonmalinowski jasonmalinowski requested a review from a team as a code owner June 6, 2023 00:41
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 6, 2023
Copy link
Member Author

Choose a reason for hiding this comment

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

VS 17.6 fixed the issues around .dic files having to be UTF-16 encoded, so we can just do this now.

{
var formatter = Services.GetRequiredLanguageService<IDocumentationCommentFormattingService>(_semanticModel.Language);
Copy link
Member Author

Choose a reason for hiding this comment

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

This logic was duplicated in ISymbolExtensions_2.cs, so it's unified now.

@jasonmalinowski jasonmalinowski self-assigned this Jun 6, 2023
@jasonmalinowski jasonmalinowski removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jun 6, 2023
using Microsoft.CodeAnalysis.Host;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.LanguageService
{
internal abstract partial class AbstractSymbolDisplayService : ISymbolDisplayService
{
protected readonly LanguageServices Services;
protected readonly IStructuralTypeDisplayService AnonymousTypeDisplayService;
Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason we were passing around both LanguageServices and also one instance of a specific language service, so cleaned up.

@@ -328,6 +328,14 @@ private void ParseCallback(XmlReader reader)
return text;
}

public DocumentationComment? GetParameter(string parameterName)
Copy link
Member Author

Choose a reason for hiding this comment

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

I should add some better doc comments here -- but to simplify handling in the other parts of the code, the idea here is if we have a member, we can create a new DocumentationComment object that has a <summary> tag with the same contents, so everything else can treat that identically.

@jasonmalinowski jasonmalinowski merged commit 91afe09 into dotnet:main Jun 7, 2023
25 checks passed
@jasonmalinowski jasonmalinowski deleted the symbol-display-service-cleanups-and-perf-improvements branch June 7, 2023 23:31
@ghost ghost added this to the Next milestone Jun 7, 2023
@RikkiGibson RikkiGibson modified the milestones: Next, 17.7 P3 Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants