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

Reduce cost of syntactic classification by around 25% while paging down through a file (and around 50% while arrowing down). #73673

Merged
merged 25 commits into from
May 24, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented May 23, 2024

Takes us from:

image

To

image

--

And from:

image

to:

image

The simple idea here is to cache more classified lines that the editor asks us about. Empirical testing showed that during page-down, we get asked for lines we were recently asked about 25% of the time, and arrowing down increased that to 85%.

By caching more (at a fixed, but larger size than the current cache), we dropped the number of times we actually have to go back to syntax by quite a bit. This helped us avoid the expensive walks of the tree, which is the limiting factor currently in large files.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 23, 2024 18:23
@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 23, 2024
@sharwell
Copy link
Member

Empirical testing showed that during page-down, we get asked for lines we were recently asked about 25% of the time, and arrowing down increased that to 85%.

How many of these cases are caused by us sending a change notification for something that didn't change (and the editor correctly responding by asking for the new data), and how many are cases where we didn't indicate a change but the editor still sent a request?

@CyrusNajmabadi
Copy link
Member Author

How many of these cases are caused by us sending a change notification for something that didn't change (and the editor correctly responding by asking for the new data), and how many are cases where we didn't indicate a change but the editor still sent a request?

None.

With syntactic classification we only trigger a reclassification in the following cases:

  1. Workspace connected (not applicable here)
  2. Workspace disconnected (not applicable here)
  3. Subject buffer changing (not applicable here, we're just scrolling, not editing).
  4. Parse options changing. Not applicable here.

It's just the case that as we're scrolling, the editor calls into us for lines they already asked about.

…sificationTaggerProvider.ClassifiedLineCache.cs
@CyrusNajmabadi CyrusNajmabadi requested a review from ToddGrun May 23, 2024 20:10
existingNode.Value.ClassifiedSpans.AddRange(classifications);
}

private void UpdateExistingEntryInCache(
Copy link
Contributor

Choose a reason for hiding this comment

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

UpdateExistingEntryInCache

Can you clarify for me when this is currently called? Same snapshot, same span, but we want to specify new values?

Copy link
Member Author

@CyrusNajmabadi CyrusNajmabadi May 23, 2024

Choose a reason for hiding this comment

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

yes.

that would happen in the case, for example, if we did an update notification (say because parse options change). We would then generate new classifications, likely at the same span as an existing span.

Copy link
Member Author

Choose a reason for hiding this comment

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

updated ot remove this.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge May 23, 2024 21:11
@@ -339,6 +339,8 @@ private ImmutableArray<LSP.Diagnostic> ConvertDiagnostic(IDiagnosticSource diagn
return [diagnostic];
}

return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems a bit odd

@CyrusNajmabadi CyrusNajmabadi disabled auto-merge May 23, 2024 22:09
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.

4 participants