Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a1d930a

Browse files
authored
[et] Print reproxy stats when RBE shuts down (#52818)
``` $ bin/et build -c ci/android_release_arm64 ─╯ [2024-05-14T11:28:40.856][ci/android_release_arm64: GN]: OK [2024-05-14T11:28:42.527][ci/android_release_arm64: RBE startup]: Proxy started successfully. [2024-05-14T11:31:14.869][ci/android_release_arm64: ninja]: 100.0% (1096/1096) STAMP obj/flutter/lib/snapshot/snapshot.stamp [2024-05-14T11:31:14.871][ci/android_release_arm64: ninja]: OK [2024-05-14T11:31:15.182][ci/android_release_arm64: RBE shutdown]: Actions completed: 1021 (569 racing locals, 452 racing remotes) ```
1 parent 1af538d commit a1d930a

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

tools/pkg/engine_build_configs/lib/src/build_config_runner.dart

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,27 @@ final class RunnerProgress extends RunnerEvent {
7676

7777
/// A [RunnerEvent] representing the result of a command.
7878
final class RunnerResult extends RunnerEvent {
79-
RunnerResult(super.name, super.command, super.timestamp, this.result);
79+
RunnerResult(
80+
super.name,
81+
super.command,
82+
super.timestamp,
83+
this.result, {
84+
this.okMessage = 'OK',
85+
});
8086

8187
/// The resuilt of running the command.
8288
final ProcessRunnerResult result;
8389

8490
/// Whether the command was successful.
8591
late final bool ok = result.exitCode == 0;
8692

93+
/// The message to print on a successful result. The default is 'OK'.
94+
final String okMessage;
95+
8796
@override
8897
String toString() {
8998
if (ok) {
90-
return '[${_timestamp(timestamp)}][$name]: OK';
99+
return '[${_timestamp(timestamp)}][$name]: $okMessage';
91100
}
92101
final StringBuffer buffer = StringBuffer();
93102
buffer.writeln('[$timestamp][$name]: FAILED');
@@ -331,6 +340,38 @@ final class BuildRunner extends Runner {
331340
return p.join(engineSrcDir.path, 'flutter', 'buildtools', platformDir);
332341
}();
333342

343+
// Returns the second line of output from reproxystatus, which contains
344+
// RBE statistics, or null if something goes wrong.
345+
Future<String?> _reproxystatus() async {
346+
final String reclientPath = p.join(_buildtoolsPath, 'reclient');
347+
final String exe = platform.isWindows ? '.exe' : '';
348+
final String restatsPath = p.join(reclientPath, 'reproxystatus$exe');
349+
final ProcessRunnerResult restatsResult;
350+
if (dryRun) {
351+
restatsResult = ProcessRunnerResult(
352+
0, // exit code.
353+
utf8.encode('OK\nOK\n'), // stdout.
354+
<int>[], // stderr.
355+
utf8.encode('OK\nOK\n'), // combined,
356+
pid: 0, // pid.
357+
);
358+
} else {
359+
restatsResult = await processRunner.runProcess(
360+
<String>[restatsPath, '-color', 'off'],
361+
failOk: true,
362+
);
363+
}
364+
if (restatsResult.exitCode != 0) {
365+
return null;
366+
}
367+
// The second line of output has the stats.
368+
final List<String> lines = restatsResult.stdout.split('\n');
369+
if (lines.length < 2) {
370+
return null;
371+
}
372+
return lines[1];
373+
}
374+
334375
Future<bool> _bootstrapRbe(
335376
RunnerEventHandler eventHandler, {
336377
bool shutdown = false,
@@ -382,11 +423,16 @@ final class BuildRunner extends Runner {
382423
failOk: true,
383424
);
384425
}
426+
String okMessage = bootstrapResult.stdout.trim();
427+
if (shutdown) {
428+
okMessage = await _reproxystatus() ?? okMessage;
429+
}
385430
eventHandler(RunnerResult(
386431
'${build.name}: RBE ${shutdown ? 'shutdown' : 'startup'}',
387432
bootstrapCommand,
388433
DateTime.now(),
389434
bootstrapResult,
435+
okMessage: okMessage,
390436
));
391437
return bootstrapResult.exitCode == 0;
392438
}

tools/pkg/engine_build_configs/test/build_config_runner_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ void main() {
230230
expect(events[6].name, equals('$buildName: RBE shutdown'));
231231
expect(events[7] is RunnerResult, isTrue);
232232
expect(events[7].name, equals('$buildName: RBE shutdown'));
233+
expect((events[7] as RunnerResult).okMessage, equals('OK'));
233234
});
234235

235236
test('GlobalBuildRunner skips GN when runGn is false', () async {

0 commit comments

Comments
 (0)