mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 09:28:55 -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;
|
package org.elasticsearch.gradle.internal.conventions.info;
|
||||||
|
|
||||||
|
import org.gradle.api.Action;
|
||||||
import org.gradle.api.logging.Logger;
|
import org.gradle.api.logging.Logger;
|
||||||
import org.gradle.api.logging.Logging;
|
import org.gradle.api.logging.Logging;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.provider.ProviderFactory;
|
import org.gradle.api.provider.ProviderFactory;
|
||||||
|
import org.gradle.process.ExecSpec;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -65,22 +67,18 @@ public class ParallelDetector {
|
||||||
}
|
}
|
||||||
_defaultParallel = socketToCore.values().stream().mapToInt(i -> i).sum();
|
_defaultParallel = socketToCore.values().stream().mapToInt(i -> i).sum();
|
||||||
} else if (isMac(project.getProviders())) {
|
} 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
|
// On Apple silicon, we only want to use the performance cores
|
||||||
boolean isAppleSilicon = project.getProviders().systemProperty("os.arch").getOrElse("").equals("aarch64");
|
boolean isAppleSilicon = project.getProviders().systemProperty("os.arch").getOrElse("").equals("aarch64");
|
||||||
String query = isAppleSilicon && isMontereyOrNewer(project.getProviders())
|
String query = isAppleSilicon && isMontereyOrNewer(project.getProviders())
|
||||||
? "hw.perflevel0.physicalcpu"
|
? "hw.perflevel0.physicalcpu"
|
||||||
: "hw.physicalcpu";
|
: "hw.physicalcpu";
|
||||||
|
|
||||||
project.exec(spec -> {
|
String stdout = project.getProviders().exec(execSpec ->
|
||||||
spec.setExecutable("sysctl");
|
execSpec.commandLine("sysctl", "-n", query)
|
||||||
spec.args("-n", query);
|
).getStandardOutput().getAsText().get();
|
||||||
spec.setStandardOutput(stdout);
|
|
||||||
});
|
|
||||||
|
|
||||||
_defaultParallel = Integer.parseInt(stdout.toString().trim());
|
|
||||||
|
_defaultParallel = Integer.parseInt(stdout.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_defaultParallel == null || _defaultParallel < 1) {
|
if (_defaultParallel == null || _defaultParallel < 1) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue