diff options
author | Brecht Van Lommel <brecht@blender.org> | 2020-10-23 19:54:45 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-10-23 20:07:34 +0300 |
commit | 23eaf3117c68f0c2bc636171dddb77630f8c8659 (patch) | |
tree | 22869950063025238d52eaa2d33c75ee86e80290 | |
parent | 6d8e03ddd991a390fb6bbc3277991b0272142c21 (diff) |
Fix Cycles unnecessary overhead cancelling finished task pool
-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 |