dart-sdk/benchmarks/EventLoopLatencyJson350KB/dart/EventLoopLatencyJson350KB.dart
Martin Kustermann c3ddc5c374 [vm/concurrency] Add EventLoopLatencyJson350KB bechmark
The existing EventLoopLatencyJson benchmark exercises the *worst case scenario*:
A background isolate is stressing the GC where the working memory set
does not fit into new space. This causes scavenges to copy the entire
newspace either into the to-space or promote it to old space.

The benchmark in this CL is similar to EventLoopLatencyJson, but it's working
memory set is significantly lower than new space, therefore not
exercising this worst case scenario (this represents the most common
scenario, which we would expect for compute() function in flutter)

(Due to difficulty sharing code between benchmarks, this CL adds
similar code as EventLoopLatencyJson)

Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: I385a620ba8900082f8ca5fb9080fc23d95112e83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169100
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-10-28 16:28:38 +00:00

35 lines
1 KiB
Dart

// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:isolate';
import 'json_benchmark.dart';
import 'latency.dart';
main() async {
// Start GC pressure from helper isolate.
final exitPort = ReceivePort();
final exitFuture = exitPort.first;
final isolate = await Isolate.spawn(run, null, onExit: exitPort.sendPort);
// Measure event loop latency.
const tickDuration = const Duration(milliseconds: 1);
const numberOfTicks = 8 * 1000; // min 8 seconds.
final EventLoopLatencyStats stats =
await measureEventLoopLatency(tickDuration, numberOfTicks);
// Kill isolate & wait until it's dead.
isolate.kill(priority: Isolate.immediate);
await exitFuture;
// Report event loop latency statistics.
stats.report('EventLoopLatencyJson350KB');
}
void run(dynamic msg) {
while (true) {
JsonRoundTripBenchmark().run();
}
}