Skip to content

Commit 1d1a6a3

Browse files
edsavagecursoragent
andcommitted
[ML] Reduce test parallelism on low-core machines to avoid flaky timing tests
Using -j numCpus on 4-core macOS CI (Orka VM) caused CKMostCorrelatedTest/testScale to fail because full CPU saturation made wall-clock based complexity assertions unreliable (exponent 2.21 vs threshold 2.1). Cap at numCpus-1 for <=4 cores to leave headroom for timing-sensitive benchmarks. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 1c0ee04 commit 1d1a6a3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ project.ext.numCpus = Runtime.runtime.availableProcessors()
116116
// Each suite spawns ctest --parallel <all_cpus> internally, so running too
117117
// many suites simultaneously causes resource contention. These values were
118118
// determined empirically (see PR #2900).
119-
// On low-core machines (<=4, e.g. macOS CI Orka VMs), use all cores since
120-
// CTest internal parallelism is modest enough that contention is minimal.
121-
project.ext.testParallel = isWindows ? 2 : (numCpus <= 4 ? numCpus : Math.max(2, (int) Math.ceil(numCpus / 3.0)))
119+
// On low-core machines (<=4, e.g. macOS CI Orka VMs with 4 cores),
120+
// cap at numCpus-1 to leave headroom for timing-sensitive tests
121+
// (e.g. CKMostCorrelatedTest/testScale). Full saturation causes
122+
// wall-clock based complexity checks to fail under contention.
123+
project.ext.testParallel = isWindows ? 2 : (numCpus <= 4 ? Math.max(2, numCpus - 1) : Math.max(2, (int) Math.ceil(numCpus / 3.0)))
122124
project.ext.makeEnvironment = [ 'CPP_CROSS_COMPILE': cppCrossCompile,
123125
'VERSION_QUALIFIER': versionQualifier,
124126
'SNAPSHOT': (isSnapshot ? 'yes' : 'no'),

dev-tools/docker/docker_entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ if [ "x$1" = "x--test" ] ; then
6868
echo passed > build/test_status.txt
6969
# Each test suite spawns ctest --parallel <nproc> internally, so limit
7070
# the number of suites running concurrently to avoid resource contention.
71-
# On low-core machines (<=4), use all cores since CTest internal
72-
# parallelism is modest enough that contention is minimal.
71+
# On low-core machines (<=4), cap at nproc-1 to leave headroom for
72+
# timing-sensitive tests (e.g. CKMostCorrelatedTest/testScale).
7373
NCPUS=$(nproc)
7474
if [ "$NCPUS" -le 4 ]; then
75-
TEST_PARALLEL=$NCPUS
75+
TEST_PARALLEL=$(( NCPUS > 2 ? NCPUS - 1 : 2 ))
7676
else
7777
TEST_PARALLEL=$(( (NCPUS + 2) / 3 ))
7878
fi

0 commit comments

Comments
 (0)