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

Too many GetMentionableUsers POST requests #2892

Closed
alexr00 opened this issue Aug 10, 2021 · 7 comments · Fixed by #2893
Closed

Too many GetMentionableUsers POST requests #2892

alexr00 opened this issue Aug 10, 2021 · 7 comments · Fixed by #2893
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release verified Verification succeeded

Comments

@alexr00
Copy link
Member

alexr00 commented Aug 10, 2021

In the JS console I can see 51 POST requests having been made to https://api.github.com/graphql. Of those, most are the result of a paginated query called GetMentionableUsers that preloads all mentionable users for this repository.

A giant repository like rails/rails will have 4304 mentionable users, which includes all org members and all prior contributors to the codebase. It will take at least 44 sequential API requests to paginate them all. It's not clear to me why a fresh VS Code instance would preload all this before this information is needed for anything. Could this load to the GitHub API be avoided?

@alexr00 alexr00 self-assigned this Aug 10, 2021
@alexr00 alexr00 added the bug Issue identified by VS Code Team member as probable bug label Aug 10, 2021
@alexr00 alexr00 added this to the August 2021 milestone Aug 10, 2021
alexr00 added a commit that referenced this issue Aug 10, 2021
@alexr00
Copy link
Member Author

alexr00 commented Aug 10, 2021

If I remove the pre-fetching of mentionable users entirely, then the @ user completion items in PR comments is unusably slow. Instead of removing the pre-fetching, it is now only done when a PR is checked out.

@mislav
Copy link

mislav commented Aug 10, 2021

@alexr00 Thanks for the quick fix!

To clarify: since this behavior is still active when a PR is checked out, is the preloading still going to be a thing if someone uses “Open in Codespaces” action for a PR in a project to open VS Code in their browser?

@alexr00
Copy link
Member Author

alexr00 commented Aug 10, 2021

Yes, the preloading will still happen in that case. The mentionable users are used for when the user types @ in a PR review comment so that we can show suggestions a username to follow the @. If we don't preload the mentionable users then we might as well not have that feature since it the suggestions won't show up for a long time (I was seeing over a minute depending on the number of users).

If this preloading is still to much, then we can consider some of the following changes:

  • Only preload users who have participated in the PR.
  • Use cached users per repository (only preload once per repository and rely on the VS Code setting sync infra to sync between sessions). If more is needed, then this is the next change I would make.
  • I'm also open to other suggestions!

@microsoft microsoft deleted a comment from mislav Aug 10, 2021
@alexr00
Copy link
Member Author

alexr00 commented Aug 10, 2021

After discussing with some folks I'll look into some further caching so that this is improved for PRs too.

@alexr00
Copy link
Member Author

alexr00 commented Aug 11, 2021

Closing for verification. Caching solution will be implemented with #2897

@alexr00 alexr00 closed this as completed Aug 11, 2021
@alexr00
Copy link
Member Author

alexr00 commented Aug 11, 2021

To verify:

  1. Install the nightly build of the extension and disable the stable build if you have it installed.
  2. Set the setting "githubPullRequests.logLevel": "debug"
  3. Open a folder in VS Code that has a GitHub repository. Make sure you're not on a branch with a PR. If you are, change branches and reload.
  4. Open the Output panel for "GitHub Pull Request".
  5. Open the Pull Requests view and wait until it no longer says "Loading..."
  6. Search for the string "Fetch mentionable users" in the Output and verify that it is not present.

@alexr00 alexr00 added the candidate Issue identified as probable candidate for fixing in the next release label Aug 11, 2021
@chrmarti
Copy link
Contributor

Verified. Also verified that it then loads when I checkout a PR and start writing a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants