Skip to content

Commit 99dbb34

Browse files
authored
Fix #301: Warning if configured nWorkers exceeds available CPU cores (#302)
1 parent e2587e0 commit 99dbb34

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

core/src/main/java/es/urjc/etsii/grafo/executors/ConcurrentExecutor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ public void executeExperiment(Experiment<S, I> experiment, List<String> instance
140140

141141
@Override
142142
public void startup() {
143+
int availableCores = Runtime.getRuntime().availableProcessors();
144+
if(this.nWorkers > availableCores){
145+
log.warn("Configured number of workers ({}) is higher than available processor cores ({}). This may lead to performance degradation due to excessive context switching.", this.nWorkers, availableCores);
146+
}
143147
this.executor = Executors.newFixedThreadPool(this.nWorkers);
144148
log.debug("Allocating threadpool with {} workers", this.nWorkers);
145149
}

0 commit comments

Comments
 (0)