Skip to content

Commit 786b6c5

Browse files
rmacnak-googleCommit Queue
authored andcommitted
[dartfuzz] Extend VM flag fuzzing to dartfuzz and iso-stress.
Extend fuzzing to run dart2wasm. Increase flag fuzzing timeout to equal generated program fuzzing timeout. Adjust dartfuzz_test and iso-stress to use relative paths for ease of copy-pasting commands for reproduction. Cq-Include-Trybots: luci.dart.try:iso-stress-linux-arm64-try,iso-stress-linux-x64-try Bug: #60804 Bug: #60805 Change-Id: I6898f30b710f26f2c624726f7affee3187804334 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430280 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Alexander Aprelev <[email protected]>
1 parent 012d84a commit 786b6c5

File tree

10 files changed

+143
-174
lines changed

10 files changed

+143
-174
lines changed

runtime/tests/concurrency/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ as part of the stress test.
1818
`generate_stress_test.dart`: Can be used to consume `stress_test_list.json` and
1919
build the stress test files.
2020

21-
`stress_test_list.json`: Contains two lists of tests (one for NNBD and one for
22-
non-NNBD) that can be used to generate a stress test.
21+
`stress_test_list.json`: Contains a list of tests that can be used to generate a
22+
stress test.
2323

24-
To ensure the list doesn't get out-of-date we have two tests on regular bots
25-
that will try to compile the stress test to kernel, thereby ensuring that the
26-
files at least exist and compile, see
27-
`runtime/tests/vm/dart/isolates/concurrency_stress_sanity_test.dart`.
24+
The stress test is run on the `iso-stress-linux-arm64` and
25+
`iso-stress-linux-x64` builders.

runtime/tests/concurrency/generate_stress_test.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ main(List<String> args) async {
2424
}
2525

2626
Future<String> generateStressTest(List<String> testFiles) async {
27-
testFiles =
28-
testFiles
29-
.map((String file) => path.absolute(path.join(thisDirectory, file)))
30-
.toList()
31-
..shuffle();
27+
testFiles = List.from(testFiles)..shuffle();
3228

3329
final sb = StringBuffer();
3430
sb.writeln(r'''
@@ -42,7 +38,7 @@ import 'dart:io';
4238
sb.writeln('import "$testFile" as test$i;');
4339
}
4440
for (int i = 0; i < testFiles.length; ++i) {
45-
final testFile = testFiles[i];
41+
final testFile = path.normalize(path.join(thisDirectory, testFiles[i]));
4642
sb.writeln('''
4743
wrapper$i(dynamic _) {
4844
print('[$testFile] starting ...');
@@ -67,7 +63,7 @@ import 'dart:io';
6763
''');
6864
sb.writeln('final List<Test> tests = [');
6965
for (int i = 0; i < testFiles.length; ++i) {
70-
final testFile = testFiles[i];
66+
final testFile = path.normalize(path.join(thisDirectory, testFiles[i]));
7167
sb.writeln(' Test("$testFile", wrapper$i),');
7268
}
7369
sb.writeln('];');

runtime/tests/concurrency/run_stress_test_shards.dart

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:path/path.dart' as path;
1212
import 'package:test_runner/src/options.dart';
1313

1414
import '../vm/dart/snapshot_test_helper.dart';
15+
import '../../tools/dartfuzz/flag_fuzzer.dart';
1516

1617
int crashCounter = 0;
1718

@@ -36,7 +37,8 @@ Future<bool> run(
3637
List<String> args,
3738
List<PotentialCrash> crashes,
3839
) async {
39-
print('Running "$executable ${args.join(' ')}"');
40+
print('\n\nRunning "$executable ${args.join(' ')}"');
41+
final sw = Stopwatch()..start();
4042
final Process process = await Process.start(
4143
executable,
4244
args,
@@ -45,6 +47,7 @@ Future<bool> run(
4547
forwardStream(process.stdout, stdout);
4648
forwardStream(process.stderr, stderr);
4749
final int exitCode = await process.exitCode;
50+
print('Completed in ${sw.elapsed}');
4851
if (exitCode != 0) {
4952
// Ignore normal exceptions and compile-time errors for the purpose of
5053
// crashdump reporting.
@@ -141,7 +144,7 @@ void writeUnexpectedCrashesFile(List<PotentialCrash> crashes) {
141144
File(unexpectedCrashesFile).writeAsStringSync(buffer.toString());
142145
}
143146

144-
const int tsanShards = 200;
147+
const int tsanShards = 64;
145148

146149
late final List<TestRunner> configurations;
147150

@@ -173,29 +176,42 @@ main(List<String> arguments) async {
173176
configurations = <TestRunner>[
174177
JitTestRunner('out/Debug$arch', [
175178
'--disable-dart-dev',
179+
...someJitRuntimeFlags(),
176180
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
177181
]),
178182
JitTestRunner('out/Release$arch', [
179183
'--disable-dart-dev',
180-
'--no-inline-alloc',
181-
'--use-slow-path',
182-
'--deoptimize-on-runtime-call-every=300',
184+
...someJitRuntimeFlags(),
183185
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
184186
]),
187+
AotTestRunner(
188+
'out/Debug$arch',
189+
[
190+
...someGenSnapshotFlags(),
191+
'runtime/tests/concurrency/generated_stress_test.dart.aot.dill',
192+
],
193+
[...someAotRuntimeFlags()],
194+
),
195+
AotTestRunner(
196+
'out/Release$arch',
197+
[
198+
...someGenSnapshotFlags(),
199+
'runtime/tests/concurrency/generated_stress_test.dart.aot.dill',
200+
],
201+
[...someAotRuntimeFlags()],
202+
),
203+
// TSAN last so the other steps are evenly distributed.
185204
for (int i = 0; i < tsanShards; ++i)
186205
JitTestRunner('out/ReleaseTSAN$arch', [
187206
'--disable-dart-dev',
207+
...someJitRuntimeFlags(),
208+
'--no-profiler', // TODO(https://github.com/dart-lang/sdk/issues/60804, https://github.com/dart-lang/sdk/issues/60805)
209+
'--no-gc_at_throw', // Too slow under TSAN
188210
'-Drepeat=4',
189211
'-Dshard=$i',
190212
'-Dshards=$tsanShards',
191213
'runtime/tests/concurrency/generated_stress_test.dart.jit.dill',
192214
]),
193-
AotTestRunner('out/Release$arch', [
194-
'runtime/tests/concurrency/generated_stress_test.dart.aot.dill',
195-
], []),
196-
AotTestRunner('out/Debug$arch', [
197-
'runtime/tests/concurrency/generated_stress_test.dart.aot.dill',
198-
], []),
199215
];
200216

201217
// Tasks will eventually be killed if they do not have any output for some

runtime/tests/concurrency/stress_test_list.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"../vm/dart/inline_TypedList_getUint32_il_test.dart",
6161
"../vm/dart/inline_local_functions_il_test.dart",
6262
"../vm/dart/inline_stack_frame_test.dart",
63-
"../vm/dart/isolates/concurrency_stress_sanity_test.dart",
6463
"../vm/dart/keep_class_names_implementing_test.dart",
6564
"../vm/dart/licm_and_assert_strengthening_test.dart",
6665
"../vm/dart/load_indexed_trivial_type_il_test.dart",

runtime/tests/vm/dart/isolates/concurrency_stress_sanity_test.dart

Lines changed: 0 additions & 61 deletions
This file was deleted.

runtime/tools/dartfuzz/dartfuzz_test.dart

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'package:args/args.dart';
1212
import 'package:matcher/matcher.dart';
1313

1414
import 'dartfuzz.dart';
15+
import 'flag_fuzzer.dart';
1516

1617
const debug = false;
1718
const sigkill = 9;
@@ -64,50 +65,10 @@ abstract class TestRunner {
6465
var prefix = mode.substring(0, 3).toUpperCase();
6566
var tag = getTag(mode);
6667
var extraFlags = <String>[];
67-
// Every once in a while, stress test JIT.
68-
if (mode.startsWith('jit') && rand.nextInt(4) == 0) {
69-
final r = rand.nextInt(7);
70-
if (r == 0) {
71-
prefix += '-NOFIELDGUARDS';
72-
extraFlags += ['--use_field_guards=false'];
73-
} else if (r == 1) {
74-
prefix += '-NOINTRINSIFY';
75-
extraFlags += ['--intrinsify=false'];
76-
} else if (r == 2) {
77-
final freq = rand.nextInt(1000) + 500;
78-
prefix += '-COMPACTEVERY-$freq';
79-
extraFlags += ['--gc_every=$freq', '--use_compactor=true'];
80-
} else if (r == 3) {
81-
final freq = rand.nextInt(1000) + 500;
82-
prefix += '-MARKSWEEPEVERY-$freq';
83-
extraFlags += ['--gc_every=$freq', '--use_compactor=false'];
84-
} else if (r == 4) {
85-
final freq = rand.nextInt(100) + 50;
86-
prefix += '-DEPOPTEVERY-$freq';
87-
extraFlags += ['--deoptimize_every=$freq'];
88-
} else if (r == 5) {
89-
final freq = rand.nextInt(100) + 50;
90-
prefix += '-STACKTRACEEVERY-$freq';
91-
extraFlags += ['--stacktrace_every=$freq'];
92-
} else if (r == 6) {
93-
prefix += '-OPTCOUNTER';
94-
extraFlags += ['--optimization_counter_threshold=1'];
95-
}
96-
}
97-
// Every once in a while, use -O3 compiler.
98-
if (!mode.startsWith('djs') && rand.nextInt(4) == 0) {
99-
prefix += '-O3';
100-
extraFlags += ['--optimization_level=3'];
101-
}
102-
// Every once in a while, use the slowpath flag.
103-
if (!mode.startsWith('djs') && rand.nextInt(4) == 0) {
104-
prefix += '-SLOWPATH';
105-
extraFlags += ['--use-slow-path'];
106-
}
107-
// Every once in a while, use the deterministic flag.
108-
if (!mode.startsWith('djs') && rand.nextInt(4) == 0) {
109-
prefix += '-DET';
110-
extraFlags += ['--deterministic'];
68+
if (mode.startsWith('jit')) {
69+
extraFlags += someJitRuntimeFlags();
70+
} else if (mode.startsWith('aot')) {
71+
extraFlags += someGenSnapshotFlags();
11172
}
11273
// Construct runner.
11374
if (mode.startsWith('jit')) {
@@ -698,7 +659,7 @@ class DartFuzzTestSession {
698659
top = Platform.environment['DART_TOP'];
699660
}
700661
if (top == null || top == '') {
701-
top = Directory.current.path;
662+
top = '.';
702663
}
703664
return top;
704665
}

0 commit comments

Comments
 (0)