Skip to content

Parallel API requests#3712

Merged
benibenj merged 3 commits intomainfrom
benibenj/performance
Jul 13, 2022
Merged

Parallel API requests#3712
benibenj merged 3 commits intomainfrom
benibenj/performance

Conversation

@benibenj
Copy link
Contributor

@benibenj benibenj commented Jul 11, 2022

All 5 requests are now performed in parallel. I have not seen any reason why they should have some sort of dependency between each other. By paralyzing the requests, a 3-4-fold speedup can be gained. It's now also caching the current user by accessing the CredentialStore

@benibenj benibenj requested a review from alexr00 July 11, 2022 11:54
@benibenj benibenj linked an issue Jul 11, 2022 that may be closed by this pull request
@benibenj benibenj added this to the July 2022 milestone Jul 11, 2022
@alexr00
Copy link
Member

alexr00 commented Jul 11, 2022

Suggested edit:

diff --git a/src/github/pullRequestModel.ts b/src/github/pullRequestModel.ts
index 498ee7f3..c920a1c6 100644
--- a/src/github/pullRequestModel.ts
+++ b/src/github/pullRequestModel.ts
@@ -783,7 +783,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
 
 			this.diffThreads(reviewThreads);
 			this._reviewThreadsCache = reviewThreads;
-
+			this._onDidChangeReviewThreads.fire({ added: reviewThreads, changed: [], removed: [] });
 			return reviewThreads;
 		} catch (e) {
 			Logger.appendLine(`Failed to get pull request review comments: ${e}`);

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

There's one change I suggested to fix a bug that this reveal, otherwise looks good.

await this.pullRequestModel.initializeReviewThreadCache();
await this.pullRequestModel.initializePullRequestFileViewState();
this._fileChanges = await this.resolveFileChangeNodes();
[, , this._fileChanges, ,] = await Promise.all([
Copy link
Member

Choose a reason for hiding this comment

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

I did a quick bit of testing of this, and I noticed that the little speech bubble character that we use as a file decoration for files with comments was no longer showing with this change. I suggested an edit that fixes the issue. This was a long standing bug that was only just revealed now that these methods are run in parallel. In short, this method was getting called when the comments threads changed, but not when they were originally set:

updateFileComments(resourceUri: vscode.Uri, prNumber: number, fileName: string, hasComments: boolean): void {
const key = `${prNumber}:${fileName}`;
const oldValue = this.fileHasComments.get(key);
if (oldValue !== hasComments) {
this.fileHasComments.set(`${prNumber}:${fileName}`, hasComments);
this._onDidChangeFileDecorations.fire(resourceUri);
}
}

@benibenj benibenj merged commit 1d65e38 into main Jul 13, 2022
@benibenj benibenj deleted the benibenj/performance branch July 13, 2022 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate performance of expanding a PR in the "Pull Requests" view

2 participants