Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave 1 processor unused on the daemon by default, fixes #111 #119

Merged
merged 1 commit into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ public ExecutionResult execute(ClientOutput output, List<String> argv) {

static void setDefaultArgs(List<String> args) {
if (args.stream().noneMatch(arg -> arg.startsWith("-T") || arg.equals("--threads"))) {
args.add("-T1C");
int procs = Runtime.getRuntime().availableProcessors() - 1;
args.add("-T" + procs);
}
if (args.stream().noneMatch(arg -> arg.startsWith("-b") || arg.equals("--builder"))) {
args.add("-bsmart");
Expand Down
4 changes: 2 additions & 2 deletions daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ private void populateRequest(CliRequest cliRequest) {
if (threadConfiguration.contains("C")) {
request.setDegreeOfConcurrency(calculateDegreeOfConcurrencyWithCoreMultiplier(threadConfiguration));
} else {
request.setDegreeOfConcurrency(Integer.valueOf(threadConfiguration));
request.setDegreeOfConcurrency(Integer.parseInt(threadConfiguration));
}
}

Expand All @@ -1020,7 +1020,7 @@ private void populateRequest(CliRequest cliRequest) {

int calculateDegreeOfConcurrencyWithCoreMultiplier(String threadConfiguration) {
int procs = Runtime.getRuntime().availableProcessors();
return (int) (Float.valueOf(threadConfiguration.replace("C", "")) * procs);
return (int) (Float.parseFloat(threadConfiguration.replace("C", "")) * procs);
}

static File resolveFile(File file, String workingDirectory) {
Expand Down