Skip to content

Commit 5f07f2b

Browse files
committed
[MINOR] Only Warn Once On Inefficient ThreadPool Use
This commit change the warning to only occur once when allocating a threadpool on a non main thread. Closes #2160 Signed-off-by: Sebastian Baunsgaard <[email protected]>
1 parent 5ac091a commit 5f07f2b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public class CommonThreadPool implements ExecutorService {
7070
/** This common thread pool */
7171
private final ExecutorService _pool;
7272

73+
/** Local variable indicating if there was a thread that was not main, and requested a thread pool */
74+
private static boolean incorrectPoolUse = false;
75+
7376
/**
7477
* Constructor of the threadPool. This is intended not to be used except for tests. Please use the static
7578
* constructors.
@@ -122,7 +125,10 @@ else if(mainThread || threadName.contains("PARFOR")) {
122125
}
123126
else {
124127
// If we are neither a main thread or parfor thread, allocate a new thread pool
125-
LOG.warn("An instruction allocated it's own thread pool indicating that some task is not properly reusing the threads.");
128+
if(!incorrectPoolUse){
129+
LOG.warn("An instruction allocated it's own thread pool indicating that some task is not properly reusing the threads.");
130+
incorrectPoolUse = true;
131+
}
126132
return Executors.newFixedThreadPool(k);
127133
}
128134

0 commit comments

Comments
 (0)