Skip to content

Commit

Permalink
Limit the number of threads used for CTW
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrodriguez committed Oct 17, 2024
1 parent c6e7912 commit 19b27ad
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public class LibGraalCompilationDriver {
private final boolean multiThreaded;

/**
* Number of threads to use for multithreaded compilation. If 0, the value of
* {@code Runtime.getRuntime().availableProcessors()} is used instead.
* Number of threads to use for multithreaded compilation. If 0, a good default value is picked
* by {@link #getThreadCount()}.
*/
private final int numThreads;

Expand Down Expand Up @@ -694,7 +694,12 @@ private int getThreadCount() {
if (multiThreaded) {
threadCount = numThreads;
if (threadCount == 0) {
threadCount = Runtime.getRuntime().availableProcessors();
/*
* On very large machine there might be hundreds of processors and the compiler
* doesn't really scale well enough for that so limit the max number of threads. 32
* was picked as that seemed to scale well enough in testing.
*/
threadCount = Math.min(32, Runtime.getRuntime().availableProcessors());
}
}
return threadCount;
Expand Down

0 comments on commit 19b27ad

Please sign in to comment.