Skip to content

Commit 2910b81

Browse files
jensjohaCommit Queue
authored andcommitted
[analyzer] Fix wrong .run call in lsp completion handler; add timing to sendResponse
E.g. when sending 2000 results to a completion request, sending (json and utf8 encoding) can be a very big part of the cost and it's very confusing having it attributed to "self" in "request". Also `mapSuggestions` looked much cheaper than it was because it used `run` instead of `runAsync`. Change-Id: Ifd219adb25fa658930548536eb8eb46276acd4a2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436922 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 863bc97 commit 2910b81

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ class CompletionHandler
549549
);
550550
}
551551

552-
var rankedResults = await performance.run('mapSuggestions', (
552+
var rankedResults = await performance.runAsync('mapSuggestions', (
553553
performance,
554554
) async {
555555
var completionItems = <({CompletionItem item, double score})>[];

pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,11 +1067,14 @@ class LspAnalysisServer extends AnalysisServer {
10671067
);
10681068
result.ifError((error) => sendErrorResponse(message, error));
10691069
result.ifResult(
1070-
(result) => sendResponse(
1071-
ResponseMessage(
1072-
id: message.id,
1073-
result: result,
1074-
jsonrpc: jsonRpcVersion,
1070+
(result) => messageInfo.performance.run(
1071+
'sendResponse',
1072+
(_) => sendResponse(
1073+
ResponseMessage(
1074+
id: message.id,
1075+
result: result,
1076+
jsonrpc: jsonRpcVersion,
1077+
),
10751078
),
10761079
),
10771080
);

0 commit comments

Comments
 (0)