[Bf-blender-cvs] [23eaf3117c6] blender-v2.91-release: Fix Cycles unnecessary overhead cancelling finished task pool
Brecht Van Lommel
noreply at git.blender.org
Fri Oct 23 19:08:15 CEST 2020
Commit: 23eaf3117c68f0c2bc636171dddb77630f8c8659
Author: Brecht Van Lommel
Date: Fri Oct 23 18:54:45 2020 +0200
Branches: blender-v2.91-release
https://developer.blender.org/rB23eaf3117c68f0c2bc636171dddb77630f8c8659
Fix Cycles unnecessary overhead cancelling finished task pool
===================================================================
M intern/cycles/util/util_task.cpp
M intern/cycles/util/util_task.h
===================================================================
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
More information about the Bf-blender-cvs
mailing list