From 9b8d9083797264af2d5c6d4c9113e6beae8af069 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 8 Jun 2026 13:27:27 -0700 Subject: [PATCH] Speed up RISCV QEMU testing. - Skip/delete some large tests. - Reduce some large tests. - Explicitly choose the CPU features, which seems to be disabling something expensive. TEST=ci Bug: https://github.com/dart-lang/sdk/issues/63465 Cq-Include-Trybots: luci.dart.try:vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try Change-Id: Ifa591d6600da3e20c9de4d123906a7747029df7e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509200 Reviewed-by: Alexander Markov Commit-Queue: Ryan Macnak --- .../lib/src/runtime_configuration.dart | 29 +++++++++++++---- pkg/test_runner/lib/src/test_suite.dart | 7 ++-- runtime/tests/vm/vm.status | 2 +- runtime/vm/benchmark_test.cc | 32 ------------------- .../assembler/assembler_riscv_test.cc | 3 +- .../vm/compiler/backend/flow_graph_test.cc | 12 ++++--- 6 files changed, 37 insertions(+), 48 deletions(-) diff --git a/pkg/test_runner/lib/src/runtime_configuration.dart b/pkg/test_runner/lib/src/runtime_configuration.dart index b2d948a7ddc..f4d87bebd0a 100644 --- a/pkg/test_runner/lib/src/runtime_configuration.dart +++ b/pkg/test_runner/lib/src/runtime_configuration.dart @@ -325,12 +325,20 @@ class JsshellRuntimeConfiguration extends CommandLineJavaScriptRuntime { } enum QemuConfig { - ia32._('qemu-i386', '/usr/lib/i386-linux-gnu/'), - x64._('qemu-x86_64', '/usr/lib/x86_64-linux-gnu/'), - arm._('qemu-arm', '/usr/arm-linux-gnueabihf/'), - arm64._('qemu-aarch64', '/usr/aarch64-linux-gnu/'), - riscv32._('qemu-riscv32', '/usr/riscv32-linux-gnu/'), - riscv64._('qemu-riscv64', '/usr/riscv64-linux-gnu/'); + ia32._('qemu-i386', 'max', '/usr/lib/i386-linux-gnu/'), + x64._('qemu-x86_64', 'max', '/usr/lib/x86_64-linux-gnu/'), + arm._('qemu-arm', 'max', '/usr/arm-linux-gnueabihf/'), + arm64._('qemu-aarch64', 'max', '/usr/aarch64-linux-gnu/'), + riscv32._( + 'qemu-riscv32', + 'rva23u32,zbc=on,zacas=on,zabha=on', + '/usr/riscv32-linux-gnu/', + ), + riscv64._( + 'qemu-riscv64', + 'rva23u64,zbc=on,zacas=on,zabha=on', + '/usr/riscv64-linux-gnu/', + ); static const all = { Architecture.ia32: QemuConfig.ia32, @@ -345,9 +353,10 @@ enum QemuConfig { }; final String executable; + final String cpu; final String elfInterpreterPrefix; - const QemuConfig._(this.executable, this.elfInterpreterPrefix); + const QemuConfig._(this.executable, this.cpu, this.elfInterpreterPrefix); @override String toString() => executable; @@ -461,6 +470,9 @@ class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration { if (environmentOverrides['QEMU_LD_PREFIX'] == null) { environmentOverrides['QEMU_LD_PREFIX'] = config.elfInterpreterPrefix; } + if (environmentOverrides['QEMU_CPU'] == null) { + environmentOverrides['QEMU_CPU'] = config.cpu; + } } var command = VMCommand(executable, arguments, environmentOverrides); if (_configuration.rr && !isCrashExpected) { @@ -499,6 +511,9 @@ class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration { if (environmentOverrides['QEMU_LD_PREFIX'] == null) { environmentOverrides['QEMU_LD_PREFIX'] = config.elfInterpreterPrefix; } + if (environmentOverrides['QEMU_CPU'] == null) { + environmentOverrides['QEMU_CPU'] = config.cpu; + } } var command = VMCommand(executable, arguments, environmentOverrides); diff --git a/pkg/test_runner/lib/src/test_suite.dart b/pkg/test_runner/lib/src/test_suite.dart index d8bfc695fb0..b5b95889fe9 100644 --- a/pkg/test_runner/lib/src/test_suite.dart +++ b/pkg/test_runner/lib/src/test_suite.dart @@ -84,6 +84,9 @@ abstract class TestSuite { if (configuration.useQemu) 'QEMU_LD_PREFIX': QemuConfig.all[configuration.architecture]!.elfInterpreterPrefix, + if (configuration.useQemu) + 'QEMU_CPU': + QemuConfig.all[configuration.architecture]!.cpu, }; Map get environmentOverrides => _environmentOverrides; @@ -334,9 +337,9 @@ class VMTestSuite extends TestSuite { if (configuration.useQemu) { final config = QemuConfig.all[configuration.architecture]!; initialHostArguments.insert(0, hostRunnerPath); - initialHostArguments.insertAll(0, ['-L', config.elfInterpreterPrefix]); + initialHostArguments.insertAll(0, ['-cpu', config.cpu, '-L', config.elfInterpreterPrefix]); initialTargetArguments.insert(0, targetRunnerPath); - initialTargetArguments.insertAll(0, ['-L', config.elfInterpreterPrefix]); + initialTargetArguments.insertAll(0, ['-cpu', config.cpu, '-L', config.elfInterpreterPrefix]); hostRunnerPath = config.executable; targetRunnerPath = config.executable; } diff --git a/runtime/tests/vm/vm.status b/runtime/tests/vm/vm.status index e796797276a..c314617dd92 100644 --- a/runtime/tests/vm/vm.status +++ b/runtime/tests/vm/vm.status @@ -250,7 +250,7 @@ dart/disassemble_determinism_test: Slow, Pass # Times out on slower bots. dart/ctrlc_handling_test: SkipByDesign [ $qemu ] -cc/ManyClasses: Slow, Pass # Generates 100k classes, slow on emulated architectures. +cc/ManyClasses: SkipSlow # Generates 100k classes, slow on emulated architectures. cc/StressMallocDirectly: Skip # Queries RSS cc/StressMallocThroughZones: Skip # Queries RSS cc/SweepDontNeed: Skip # Queries RSS diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc index f7cee85e826..e1ddc40e281 100644 --- a/runtime/vm/benchmark_test.cc +++ b/runtime/vm/benchmark_test.cc @@ -531,38 +531,6 @@ BENCHMARK(SimpleMessage) { benchmark->set_score(elapsed_time); } -BENCHMARK(LargeMap) { - const char* kScript = - "@pragma('vm:entry-point', 'call')\n" - "makeMap() {\n" - " Map m = {};\n" - " for (int i = 0; i < 100000; ++i) m[i*13+i*(i>>7)] = i;\n" - " return m;\n" - "}"; - Dart_Handle h_lib = TestCase::LoadTestScript(kScript, nullptr); - EXPECT_VALID(h_lib); - Dart_Handle h_result = Dart_Invoke(h_lib, NewString("makeMap"), 0, nullptr); - EXPECT_VALID(h_result); - TransitionNativeToVM transition(thread); - StackZone zone(thread); - Instance& map = Instance::Handle(); - map ^= Api::UnwrapHandle(h_result); - const intptr_t kLoopCount = 100; - Timer timer; - timer.Start(); - for (intptr_t i = 0; i < kLoopCount; i++) { - StackZone zone(thread); - std::unique_ptr message = WriteMessage( - /* same_group */ false, map, ILLEGAL_PORT, Message::kNormalPriority); - - // Read object back from the snapshot. - ReadMessage(thread, message.get()); - } - timer.Stop(); - int64_t elapsed_time = timer.TotalElapsedTime(); - benchmark->set_score(elapsed_time); -} - BENCHMARK_MEMORY(InitialRSS) { benchmark->set_score(bin::Process::MaxRSS()); } diff --git a/runtime/vm/compiler/assembler/assembler_riscv_test.cc b/runtime/vm/compiler/assembler/assembler_riscv_test.cc index 858aa0bc96b..ab0da0b5dfe 100644 --- a/runtime/vm/compiler/assembler/assembler_riscv_test.cc +++ b/runtime/vm/compiler/assembler/assembler_riscv_test.cc @@ -1785,7 +1785,8 @@ ASSEMBLER_TEST_RUN(InstructionFence, test) { EXPECT_DISASSEMBLY( "0000100f fence.i\n" "00008067 ret\n"); - Call(test->entry()); + + // Not running: may trap. This was removed from the user ISA. } ASSEMBLER_TEST_GENERATE(EnvironmentCall, assembler) { diff --git a/runtime/vm/compiler/backend/flow_graph_test.cc b/runtime/vm/compiler/backend/flow_graph_test.cc index 26d6a54b39f..97dbdfd308b 100644 --- a/runtime/vm/compiler/backend/flow_graph_test.cc +++ b/runtime/vm/compiler/backend/flow_graph_test.cc @@ -201,6 +201,8 @@ void TestLargeFrame(const char* type, const char* one, const char* main) { SetFlagScope sfs(&FLAG_optimization_counter_threshold, 1000); + SetFlagScope sfs2(&FLAG_background_compilation, false); + TextBuffer printer(256 * KB); intptr_t num_locals = 2000; @@ -233,7 +235,7 @@ void TestLargeFrame(const char* type, ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Int) { TestLargeFrame("int", "0", "1", "main() {\n" - " for (var i = 0; i < 100; i++) {\n" + " for (var i = 0; i < 3; i++) {\n" " var r = largeFrame(1);\n" " if (r != 2000) throw r;\n" " }\n" @@ -244,7 +246,7 @@ ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Int) { ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Double) { TestLargeFrame("double", "0.0", "1.0", "main() {\n" - " for (var i = 0; i < 100; i++) {\n" + " for (var i = 0; i < 3; i++) {\n" " var r = largeFrame(1);\n" " if (r != 2000.0) throw r;\n" " }\n" @@ -255,7 +257,7 @@ ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Double) { ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Int32x4) { TestLargeFrame("Int32x4", "Int32x4(0, 0, 0, 0)", "Int32x4(1, 2, 3, 4)", "main() {\n" - " for (var i = 0; i < 100; i++) {\n" + " for (var i = 0; i < 3; i++) {\n" " var r = largeFrame(1);\n" " if (r.x != 2000) throw r;\n" " if (r.y != 4000) throw r;\n" @@ -270,7 +272,7 @@ ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Float32x4) { TestLargeFrame("Float32x4", "Float32x4(0.0, 0.0, 0.0, 0.0)", "Float32x4(1.0, 2.0, 3.0, 4.0)", "main() {\n" - " for (var i = 0; i < 100; i++) {\n" + " for (var i = 0; i < 3; i++) {\n" " var r = largeFrame(1);\n" " if (r.x != 2000.0) throw r;\n" " if (r.y != 4000.0) throw r;\n" @@ -284,7 +286,7 @@ ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Float32x4) { ISOLATE_UNIT_TEST_CASE(FlowGraph_LargeFrame_Float64x2) { TestLargeFrame("Float64x2", "Float64x2(0.0, 0.0)", "Float64x2(1.0, 2.0)", "main() {\n" - " for (var i = 0; i < 100; i++) {\n" + " for (var i = 0; i < 3; i++) {\n" " var r = largeFrame(1);\n" " if (r.x != 2000.0) throw r;\n" " if (r.y != 4000.0) throw r;\n"