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

Clean up FAR aggregation #48619

Merged
merged 11 commits into from
May 19, 2022
Merged

Clean up FAR aggregation #48619

merged 11 commits into from
May 19, 2022

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented Apr 9, 2022

We have library functions for searching within a project for symbols, references, rename locations, etc. All of that code is exactly as before - this change is about the layer that sits on top of that and aggregates the results across multiple projects. In the course of some performance investigations, I discovered that user-FAR was invoking per-project-FAR more times than I expected and that the code wasn't readable enough for me to confidently determine why or how to prevent it. This change attempts to address both issues.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Apr 9, 2022
@amcasey amcasey changed the title Far cleanup redux Clean up FAR aggregation Apr 9, 2022
@amcasey
Copy link
Member Author

amcasey commented Apr 9, 2022

From #48211

Benefits:

  1. Uninverted callbacks
  2. Intelligible meaning for isDefinition
  3. Does fewer redundant searches when projects are already loaded

Costs:

  1. Does more tsconfig searches (probably negligible cost)
  2. isDefinition is computed multiple times for projects other than the initial project

Rough explanation of the new isDefinition:

  1. Start at the place the user invoked FAR (this is surprisingly hard to find)
  2. Record that location in a set of spans known to refer to the "real" symbol
  3. Find a project with a result in the known set
  4. Find the symbol at that position in that project
  5. Use that symbol to compute isDefinition for each declaration in the results for that project and add those that refer to the symbol to the set
  6. Goto (3) until no such project is found
  7. Clear isDefinition in all remaining projects

@amcasey
Copy link
Member Author

amcasey commented Apr 9, 2022

@sheetalkamat I know @andrewbranch prefers the reduced complexity of this simplification, but I find its correctness less intuitively obvious. What are your thoughts on reverting that simplification commit?

amcasey added a commit to amcasey/TypeScript that referenced this pull request May 5, 2022
Getting an empty result doesn't seem expected, but a deeper fix doesn't make sense until microsoft#48619 is merged.

Fixes microsoft#48963
amcasey added a commit to amcasey/TypeScript that referenced this pull request May 5, 2022
Getting an empty result doesn't seem expected, but a deeper fix doesn't make sense until microsoft#48619 is merged.

Fixes microsoft#48963
DanielRosenwasser pushed a commit that referenced this pull request May 5, 2022
Getting an empty result doesn't seem expected, but a deeper fix doesn't make sense until #48619 is merged.

Fixes #48963
amcasey added 11 commits May 17, 2022 09:36
This change had two goals:

1. Make the code easier to understand, primarily by simplifying the callback structure and minimizing side-effects
2. Improve performance by reducing repeated work, both FAR searches of individual projects and default tsconfig searches

This implementation attempts to preserve the merging order found in the original code (someone less relevant in the present state of using syntactic isDefinition).
...in preparation for implementing isDefinition explicitly.

Also restore convention of referring to `DocumentPosition`s as "locations".
...to allow use of the checker when computing isDefinition across projects.
@amcasey amcasey force-pushed the FarCleanupRedux branch from 284b0ac to 827f5f3 Compare May 17, 2022 19:41
@amcasey
Copy link
Member Author

amcasey commented May 17, 2022

cc @gabritto for the merge of #48758 (the non-trivial parts of which are in d47ae8a).

@amcasey
Copy link
Member Author

amcasey commented May 17, 2022

Ping @sheetalkamat @andrewbranch now that we're in 4.8, this is ready for review.

@amcasey amcasey merged commit 12ed012 into microsoft:main May 19, 2022
@amcasey amcasey deleted the FarCleanupRedux branch May 19, 2022 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants