From a1b43088a4169ae6e811a4e8c4d32ff519f159c4 Mon Sep 17 00:00:00 2001 From: "Hochsteger, Matthias" Date: Sun, 21 May 2023 14:41:41 +0200 Subject: [PATCH] TaskManager - sleep when no jobs for some time --- libsrc/core/taskmanager.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libsrc/core/taskmanager.cpp b/libsrc/core/taskmanager.cpp index 875746ec..f57be4db 100644 --- a/libsrc/core/taskmanager.cpp +++ b/libsrc/core/taskmanager.cpp @@ -485,6 +485,7 @@ namespace ngcore #endif + size_t no_job_counter = 0; while (!done) { if (complete[mynode] > jobdone) @@ -492,11 +493,12 @@ namespace ngcore if (jobnr == jobdone) { + no_job_counter++; // RegionTracer t(ti.thread_nr, tCASyield, ti.task_nr); - while (ProcessTask()); // do the nested tasks + while (ProcessTask()) no_job_counter = 0; // do the nested tasks - if(sleep) - std::this_thread::sleep_for(std::chrono::microseconds(sleep_usecs)); + if(sleep || no_job_counter > 10000) + std::this_thread::sleep_for(std::chrono::microseconds(10)); else { #ifdef WIN32 @@ -537,6 +539,7 @@ namespace ngcore ti.task_nr = mytasks.First()+mytask; ti.ntasks = ntasks; + no_job_counter = 0; { RegionTracer t(ti.thread_nr, jobnr, RegionTracer::ID_JOB, ti.task_nr);