diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-10-23 19:54:45 +0300 |
---|---|---|
committer | Howard Trickey <howard.trickey@gmail.com> | 2020-10-24 21:07:05 +0300 |
commit | b37c40a575663ea42d397d57d3ef902b4d9777ec (patch) | |
tree | a1e21acd91645b89305f45bd922ef9c576b14b43 /intern/cycles | |
parent | 594f47ecd2d5367ca936cf6fc6ec8168c2b360d0 (diff) |
Fix Cycles unnecessary overhead cancelling finished task pool
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/util/util_task.cpp | 15 | ||||
-rw-r--r-- | intern/cycles/util/util_task.h | 4 |
2 files changed, 12 insertions, 7 deletions
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp index 4fb61392e92..50c236ac968 100644 --- a/intern/cycles/util/util_task.cpp +++ b/intern/cycles/util/util_task.cpp @@ -24,7 +24,7 @@ CCL_NAMESPACE_BEGIN /* Task Pool */ -TaskPool::TaskPool() : start_time(time_dt()), num_tasks_handled(0) +TaskPool::TaskPool() : start_time(time_dt()), num_tasks_pushed(0) { } @@ -36,7 +36,7 @@ TaskPool::~TaskPool() void TaskPool::push(TaskRunFunction &&task) { tbb_group.run(std::move(task)); - num_tasks_handled++; + num_tasks_pushed++; } void TaskPool::wait_work(Summary *stats) @@ -45,14 +45,19 @@ void TaskPool::wait_work(Summary *stats) if (stats != NULL) { stats->time_total = time_dt() - start_time; - stats->num_tasks_handled = num_tasks_handled; + stats->num_tasks_handled = num_tasks_pushed; } + + num_tasks_pushed = 0; } void TaskPool::cancel() { - tbb_group.cancel(); - tbb_group.wait(); + if (num_tasks_pushed > 0) { + tbb_group.cancel(); + tbb_group.wait(); + num_tasks_pushed = 0; + } } bool TaskPool::canceled() diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index d3c3c11f8e2..f2718600f30 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -71,8 +71,8 @@ class TaskPool { /* Time time stamp of first task pushed. */ double start_time; - /* Number of all tasks handled by this pool. */ - int num_tasks_handled; + /* Number of all tasks pushed to the pool. Cleared after wait_work() and cancel(). */ + int num_tasks_pushed; }; /* Task Scheduler |