From fda59ff96983394622235926465d9058fbfd3076 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 19 Nov 2018 14:01:32 +0200 Subject: [PATCH] The default of tests.jvms should not be capped (#35259) Default to the number of physical cores across all sockets instead. --- TESTING.asciidoc | 5 ++-- .../elasticsearch/gradle/BuildPlugin.groovy | 25 ++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/TESTING.asciidoc b/TESTING.asciidoc index f0e5b87c6e0..36eb5cfbc5e 100644 --- a/TESTING.asciidoc +++ b/TESTING.asciidoc @@ -150,8 +150,9 @@ Default value provided below in [brackets]. === Load balancing and caches. -By default the tests run on up to 4 JVMs based on the number of cores. If you -want to explicitly specify the number of JVMs you can do so on the command +By default the tests run on multiple processes using all the available cores on all +available CPUs. Not including hyper-threading. +If you want to explicitly specify the number of JVMs you can do so on the command line: ---------------------------- diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index f46e7f363ca..507e07dd16c 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -773,9 +773,32 @@ class BuildPlugin implements Plugin { } static void applyCommonTestConfig(Project project) { + String defaultParallel = 'auto' + // Count physical cores on any Linux distro ( don't count hyper-threading ) + if (project.file("/proc/cpuinfo").exists()) { + Map socketToCore = [:] + String currentID = "" + project.file("/proc/cpuinfo").readLines().forEach({ line -> + if (line.contains(":")) { + List parts = line.split(":", 2).collect({it.trim()}) + String name = parts[0], value = parts[1] + // the ID of the CPU socket + if (name == "physical id") { + currentID = value + } + // Number of cores not including hyper-threading + if (name == "cpu cores") { + assert currentID.isEmpty() == false + socketToCore[currentID] = Integer.valueOf(value) + currentID = "" + } + } + }) + defaultParallel = socketToCore.values().sum().toString(); + } project.tasks.withType(RandomizedTestingTask) { jvm "${project.runtimeJavaHome}/bin/java" - parallelism System.getProperty('tests.jvms', 'auto') + parallelism System.getProperty('tests.jvms', defaultParallel) ifNoTests System.getProperty('tests.ifNoTests', 'fail') onNonEmptyWorkDirectory 'wipe' leaveTemporary true