From 5dbeea95d0e1eb61eaa52dc5943d143f3b2e490c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 9 May 2016 11:58:36 +0200 Subject: [PATCH] Depsgraph: Avoid having per-node lock when scheduling children Use atomic operations instead, should in theory improve timing of scheduling. However, probably not so visible yet because actual task scheduling still have some locks and memory allocations. Baby steps, what would i say. --- source/blender/depsgraph/intern/depsgraph_eval.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc index fb6722cc893..15c8b1a9dd3 100644 --- a/source/blender/depsgraph/intern/depsgraph_eval.cc +++ b/source/blender/depsgraph/intern/depsgraph_eval.cc @@ -248,12 +248,8 @@ static void schedule_node(TaskPool *pool, Depsgraph *graph, int layers, } if (node->num_links_pending == 0) { - BLI_spin_lock(&graph->lock); - bool need_schedule = !node->scheduled; - node->scheduled = true; - BLI_spin_unlock(&graph->lock); - - if (need_schedule) { + bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t*)&node->scheduled, (uint8_t)true); + if (!is_scheduled) { if (node->is_noop()) { /* skip NOOP node, schedule children right away */ schedule_children(pool, graph, node, layers);