mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-27 17:10:22 -04:00
Fix paralle detector configuration cache compatibility (#95452)
This commit is contained in:
parent
486dfc8ea2
commit
2b210b5220
1 changed files with 7 additions and 9 deletions
|
@ -8,10 +8,12 @@
|
|||
|
||||
package org.elasticsearch.gradle.internal.conventions.info;
|
||||
|
||||
import org.gradle.api.Action;
|
||||
import org.gradle.api.logging.Logger;
|
||||
import org.gradle.api.logging.Logging;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.provider.ProviderFactory;
|
||||
import org.gradle.process.ExecSpec;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -65,22 +67,18 @@ public class ParallelDetector {
|
|||
}
|
||||
_defaultParallel = socketToCore.values().stream().mapToInt(i -> i).sum();
|
||||
} else if (isMac(project.getProviders())) {
|
||||
// Ask macOS to count physical CPUs for us
|
||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||
|
||||
// On Apple silicon, we only want to use the performance cores
|
||||
boolean isAppleSilicon = project.getProviders().systemProperty("os.arch").getOrElse("").equals("aarch64");
|
||||
String query = isAppleSilicon && isMontereyOrNewer(project.getProviders())
|
||||
? "hw.perflevel0.physicalcpu"
|
||||
: "hw.physicalcpu";
|
||||
|
||||
project.exec(spec -> {
|
||||
spec.setExecutable("sysctl");
|
||||
spec.args("-n", query);
|
||||
spec.setStandardOutput(stdout);
|
||||
});
|
||||
String stdout = project.getProviders().exec(execSpec ->
|
||||
execSpec.commandLine("sysctl", "-n", query)
|
||||
).getStandardOutput().getAsText().get();
|
||||
|
||||
_defaultParallel = Integer.parseInt(stdout.toString().trim());
|
||||
|
||||
_defaultParallel = Integer.parseInt(stdout.trim());
|
||||
}
|
||||
|
||||
if (_defaultParallel == null || _defaultParallel < 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue