From aa9dd7be5fab191a215c022e0dbcef02c567dffe Mon Sep 17 00:00:00 2001 From: Jarek Prokop Date: Tue, 14 Oct 2025 18:29:12 +0200 Subject: [PATCH] Enable parallel 'make check'. Use a build condition to turn the parallelization on and off when needed. The output is slightly different from the previous approach. The way results are collected and displayed remains the same. This allows us to scale down build time on multiple cores better. Chose to introduce a bcond explicitly for tests for debugging purposes. Running tests in parallel could hide issues that would show if everything was done in a single test-unit process. Limiting the number of cores available to RPM via a macro would also hinder parallelization of the compilation, which might not be desired in the case of only wanting to serializing the tests. Table from the associated ticket: The time represents total seconds that a full RPM build inside mock took from start to finish. PARALLEL TESTS ------------------------------------------------------------------------ Cores | Runs | Avg (s) | Min (s) | Max (s) | Speedup ------------------------------------------------------------------------ 2_core | 5 | 3196.0 | 3175.0 | 3218.0 | 1.00x 4_core | 5 | 3166.6 | 2949.0 | 3598.0 | 1.01x 8_core | 5 | 1129.2 | 1090.0 | 1257.0 | 2.83x 16_core | 5 | 807.4 | 794.0 | 820.0 | 3.96x SEQUENTIAL TESTS ------------------------------------------------------------------------ Cores | Runs | Avg (s) | Min (s) | Max (s) | Speedup ------------------------------------------------------------------------ 2_core | 5 | 3749.6 | 3728.0 | 3772.0 | 1.00x 4_core | 5 | 3368.8 | 3128.0 | 3539.0 | 1.11x 8_core | 5 | 1810.6 | 1764.0 | 1912.0 | 2.07x 16_core | 5 | 1612.8 | 1571.0 | 1646.0 | 2.32x PARALLEL vs SEQUENTIAL COMPARISON ------------------------------------------------------------------------- Cores | Sequential Avg | Parallel Avg | Difference ------------------------------------------------------------------------- 2_core | 3749.6 s | 3196.0 s | +17.3% 4_core | 3368.8 s | 3166.6 s | +6.4% 8_core | 1810.6 s | 1129.2 s | +60.3% 16_core | 1612.8 s | 807.4 s | +99.8% Resolves: rhbz#2401230 --- ruby.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ruby.spec b/ruby.spec index 619082d..dc220ee 100644 --- a/ruby.spec +++ b/ruby.spec @@ -165,6 +165,7 @@ %endif # Enable test when building on local. %bcond_with bundler_tests +%bcond_without parallel_tests %if 0%{?fedora} %bcond_without hardening_test @@ -1212,7 +1213,7 @@ MSPECOPTS="" # Give an option to increase the timeout in tests. # https://bugs.ruby-lang.org/issues/16921 %{?test_timeout_scale:RUBY_TEST_TIMEOUT_SCALE="%{test_timeout_scale}"} \ - make -C %{_vpath_builddir} check TESTS="-v --show-skip $DISABLE_TESTS" MSPECOPT="-fs $MSPECOPTS" + make -C %{_vpath_builddir} %{?with_parallel_tests:%{?_smp_mflags}} check TESTS="-v --show-skip $DISABLE_TESTS" MSPECOPT="-fs $MSPECOPTS" # Run Ruby OpenSSL tests in OpenSSL FIPS. make -C %{_vpath_builddir} runruby TESTRUN_SCRIPT=" \