Skip to content

Commit dafe470

Browse files
scheglovCommit Bot
authored and
Commit Bot
committed
Update completion benchmarks to the new protocol.
Stop subscribing for AVAILABLE_SUGGESTION_SETS. Change-Id: I93aa0f1227d766346a115327d1f79e95739a2435 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240761 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 6a41e19 commit dafe470

File tree

3 files changed

+14
-38
lines changed

3 files changed

+14
-38
lines changed

pkg/analysis_server/benchmark/perf/benchmarks_impl.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class AnalysisBenchmark extends Benchmark {
7676
var stopwatch = Stopwatch()..start();
7777

7878
Future _complete(int offset) async {
79-
await test.complete(filePath, offset);
79+
await test.complete(filePath, offset, isWarmUp: false);
8080
completionCount++;
8181
}
8282

pkg/analysis_server/benchmark/perf/flutter_completion_benchmark.dart

+4-8
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ class FlutterCompletionBenchmark extends Benchmark implements FlutterBenchmark {
144144
// about all these libraries. We change a method body, so the API
145145
// signature is the same, and we are able to reload these libraries
146146
// from bytes. But this still costs something.
147-
// There is also a spill-over from the previous test - we send a lot
148-
// (about 5MB) of available declarations after each change. This makes
149-
// completion response times very large.
150-
// TODO(scheglov) Remove the previous sentence when improved.
151147
// Total number of suggestions: 3429.
152148
// Filtered to: 133.
153149
// Long name: completion-mediumLibraryCycle-mediumFile-smallBody
@@ -219,7 +215,7 @@ class FlutterCompletionBenchmark extends Benchmark implements FlutterBenchmark {
219215

220216
await test.openFile(filePath, fileContent);
221217

222-
Future<void> perform() async {
218+
Future<void> perform({required bool isWarmUp}) async {
223219
var completionOffset = prefixEnd;
224220

225221
if (insertStringGenerator != null) {
@@ -234,7 +230,7 @@ class FlutterCompletionBenchmark extends Benchmark implements FlutterBenchmark {
234230
);
235231
}
236232

237-
await test.complete(filePath, completionOffset);
233+
await test.complete(filePath, completionOffset, isWarmUp: isWarmUp);
238234

239235
if (insertStringGenerator != null) {
240236
await test.updateFile(filePath, fileContent);
@@ -246,13 +242,13 @@ class FlutterCompletionBenchmark extends Benchmark implements FlutterBenchmark {
246242
// The sustained performance is much more important.
247243
const kWarmUpCount = 5;
248244
for (var i = 0; i < kWarmUpCount; i++) {
249-
await perform();
245+
await perform(isWarmUp: true);
250246
}
251247

252248
const kRepeatCount = 5;
253249
final timer = Stopwatch()..start();
254250
for (var i = 0; i < kRepeatCount; i++) {
255-
await perform();
251+
await perform(isWarmUp: false);
256252
}
257253

258254
await test.closeFile(filePath);

pkg/analysis_server/benchmark/perf/memory_tests.dart

+9-29
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import '../../test/lsp/server_abstract.dart' show ClientCapabilitiesHelperMixin;
2121
abstract class AbstractBenchmarkTest {
2222
Future<void> get analysisFinished;
2323
Future<void> closeFile(String filePath);
24-
Future<void> complete(String filePath, int offset);
24+
Future<void> complete(String filePath, int offset, {required bool isWarmUp});
2525
void debugStdio();
2626
Future<int> getMemoryUsage();
2727
Future<void> openFile(String filePath, String contents);
@@ -44,22 +44,13 @@ class AnalysisServerBenchmarkTest extends AbstractBenchmarkTest {
4444
_test.sendAnalysisUpdateContent({filePath: RemoveContentOverlay()});
4545

4646
@override
47-
Future<void> complete(String filePath, int offset) async {
48-
// Create a new non-broadcast stream and subscribe to
49-
// test.onCompletionResults before sending a request.
50-
// Otherwise we could skip results which where posted to
51-
// test.onCompletionResults after request is sent but
52-
// before subscribing to test.onCompletionResults.
53-
final completionResults = StreamController<CompletionResultsParams>();
54-
completionResults.sink.addStream(_test.onCompletionResults);
55-
56-
var result = await _test.sendCompletionGetSuggestions(filePath, offset);
57-
58-
var future = completionResults.stream
59-
.where((CompletionResultsParams params) =>
60-
params.id == result.id && params.isLast)
61-
.first;
62-
await future;
47+
Future<void> complete(
48+
String filePath,
49+
int offset, {
50+
required bool isWarmUp,
51+
}) async {
52+
await _test.sendCompletionGetSuggestions2(filePath, offset, 100,
53+
timeout: isWarmUp ? 60 * 1000 : 0);
6354
}
6455

6556
@override
@@ -80,7 +71,6 @@ class AnalysisServerBenchmarkTest extends AbstractBenchmarkTest {
8071
_test.dartSdkPath = dartSdkPath;
8172
await _test.setUp();
8273
await _test.subscribeToStatusNotifications();
83-
await _test.subscribeToAvailableSuggestions();
8474
await _test.sendAnalysisSetAnalysisRoots(roots, []);
8575
}
8676

@@ -129,16 +119,6 @@ class AnalysisServerMemoryUsageTest
129119
/// After every test, the server is stopped.
130120
Future shutdown() async => await shutdownIfNeeded();
131121

132-
/// Enable using available suggestions during completion.
133-
Future<void> subscribeToAvailableSuggestions() async {
134-
await server.send(
135-
'completion.setSubscriptions',
136-
CompletionSetSubscriptionsParams(
137-
[CompletionService.AVAILABLE_SUGGESTION_SETS],
138-
).toJson(),
139-
);
140-
}
141-
142122
/// Enable [ServerService.STATUS] notifications so that [analysisFinished]
143123
/// can be used.
144124
Future subscribeToStatusNotifications() async {
@@ -168,7 +148,7 @@ class LspAnalysisServerBenchmarkTest extends AbstractBenchmarkTest
168148
}
169149

170150
@override
171-
Future<void> complete(String filePath, int offset) {
151+
Future<void> complete(String filePath, int offset, {required bool isWarmUp}) {
172152
final contents = _fileContents[filePath]!;
173153
final position = _test.positionFromOffset(offset, contents);
174154
return _test.getCompletion(Uri.file(filePath), position);

0 commit comments

Comments
 (0)