This is an automated email from the ASF dual-hosted git repository.
baunsgaard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push:
new 5f07f2b13a [MINOR] Only Warn Once On Inefficient ThreadPool Use
5f07f2b13a is described below
commit 5f07f2b13af6d5b7c99f8d5943b1879987594236
Author: Sebastian Baunsgaard <[email protected]>
AuthorDate: Sat Dec 28 14:31:22 2024 +0100
[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]>
---
src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java
b/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java
index ae205c6850..bad708d691 100644
--- a/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java
+++ b/src/main/java/org/apache/sysds/runtime/util/CommonThreadPool.java
@@ -70,6 +70,9 @@ public class CommonThreadPool implements ExecutorService {
/** This common thread pool */
private final ExecutorService _pool;
+ /** Local variable indicating if there was a thread that was not main,
and requested a thread pool */
+ private static boolean incorrectPoolUse = false;
+
/**
* Constructor of the threadPool. This is intended not to be used
except for tests. Please use the static
* constructors.
@@ -122,7 +125,10 @@ public class CommonThreadPool implements ExecutorService {
}
else {
// If we are neither a main thread or parfor thread,
allocate a new thread pool
- LOG.warn("An instruction allocated it's own thread pool
indicating that some task is not properly reusing the threads.");
+ if(!incorrectPoolUse){
+ LOG.warn("An instruction allocated it's own
thread pool indicating that some task is not properly reusing the threads.");
+ incorrectPoolUse = true;
+ }
return Executors.newFixedThreadPool(k);
}