Skip to content

Commit

Permalink
Merge pull request #119 from gnodet/issue-111
Browse files Browse the repository at this point in the history
Leave 1 processor unused on the daemon by default, fixes #111
  • Loading branch information
ppalaga authored Oct 21, 2020
2 parents 68b14f0 + 3fb67e4 commit 1b18bd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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

0 comments on commit 1b18bd4

Please sign in to comment.