Skip to content

Lazy doc comments for signature help - #458

Merged
pharring merged 9 commits into
dotnet:masterfrom
pharring:DocComment2
Feb 13, 2015
Merged

Lazy doc comments for signature help#458
pharring merged 9 commits into
dotnet:masterfrom
pharring:DocComment2

Conversation

@pharring

Copy link
Copy Markdown
Contributor

This change makes XML documentation comment lookup and parsing for signature help lazy.

Cache the result of the most recent call to
DocumentationComment.FromXmlFragment.
Avoid parsing XML to determine completion list type if the text doesn't
contain the word "completionlist"
Realize the Documentation for signature help items lazily.
@pharring

Copy link
Copy Markdown
Contributor Author

@rchande, please take a look.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

any reason it has to be created ToArray()? foreach seems would just work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As the note says, I want to avoid enumerating more than once. If I used the IEnumerable, there would be one for the ".Count > 0" check (I would call the .Any() extension method), then there would be two more to call AddRange and Append on lines 202-203.

This is subtle and one of the things I was looking for feedback on. The types I changed are carefully selected to avoid early evaluation by switching to an iterator and threading IEnumerable through to this line. The downside is that, if you enumerate more than once, you incur a 2nd parsing cost.

Now, this could probably be fixed by using a custom iterator type. One that is lazy (doesn't do any work until you call GetEnumerator), but fast for subsequent calls.

@heejaechang

Copy link
Copy Markdown
Contributor

👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can _parameterIndex >= _parameters.Length ever be true?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If it can, I'm prepared to take the IndexOutOfRangeException. I can add validation in the constructor.

…for Documentation in SignatureHelp and thread that through the entire sig-help implementation.
@CyrusNajmabadi

Copy link
Copy Markdown
Contributor

@pharring Ok, i hate to be that guy. But 19 allocations/instances per character sounds like literally nothing. I'm guessing that's orders of magnitude less than the number of objects created by the rest of the system during typing. I'm all for efficiency and cutting down on things. But normally in areas where there's a lot created, such that the savings is actually measurably better. But avoiding lazys just to save a literal handful of allocations seems... excessive.

Just my 2c though :)

@rchande

rchande commented Feb 13, 2015

Copy link
Copy Markdown
Contributor

👍

@dpoeschl dpoeschl added Area-IDE Tenet-Performance Regression in measured performance of the product from goals. labels Feb 13, 2015
@pharring

Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi Well, since you gave me the option, I'll just make this change and let you fix up Typescript. Will send email too.

Use compact property getter syntax.
Added range checking to Signature's constructor.
Fixed a NullReferenceException introduced by the last commit (range
validation)
pharring added a commit that referenced this pull request Feb 13, 2015
Lazy doc comments for signature help

Made the retrieval and parsing of XML documentation comments for signature help items lazy. This saves allocations and CPU time for operations such as typing within methods like Console.WriteLine (which has 19 overloads)

Also, cache the result of the last XML fragment parse (since we often ask to parse the same fragment over and over)
@pharring
pharring merged commit f1423e2 into dotnet:master Feb 13, 2015
@pharring
pharring deleted the DocComment2 branch February 13, 2015 22:35
dibarbet pushed a commit that referenced this pull request Aug 18, 2026
Verify content before iteration counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Tenet-Performance Regression in measured performance of the product from goals.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants