Change the policy for number of threads

This commit is contained in:
Henrik Rydgård
2021-06-12 13:03:54 +02:00
parent 5fd15c06a3
commit a9e9929a72
+5 -1
View File
@@ -1,4 +1,5 @@
#include <cstdio>
#include <algorithm>
#include <thread>
#include <deque>
#include <condition_variable>
@@ -121,7 +122,10 @@ void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task, TaskType task
}
int ThreadManager::GetNumLooperThreads() const {
return (int)(global_->threads_.size() / 2);
// If possible, let's use all threads but one for parallel loops.
// Not sure what's the best policy here. Maybe we should just have more threads than CPUs.
int numLooperThreads = (int)(global_->threads_.size()) - 1;
return std::max(numLooperThreads, 1);
}
void ThreadManager::TryCancelTask(uint64_t taskID) {