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.
This commit is contained in:
Sergey Sharybin
2016-05-09 11:58:36 +02:00
parent dc5e02c42c
commit 5dbeea95d0

View File

@@ -248,12 +248,8 @@ static void schedule_node(TaskPool *pool, Depsgraph *graph, int layers,
} }
if (node->num_links_pending == 0) { if (node->num_links_pending == 0) {
BLI_spin_lock(&graph->lock); bool is_scheduled = atomic_fetch_and_or_uint8((uint8_t*)&node->scheduled, (uint8_t)true);
bool need_schedule = !node->scheduled; if (!is_scheduled) {
node->scheduled = true;
BLI_spin_unlock(&graph->lock);
if (need_schedule) {
if (node->is_noop()) { if (node->is_noop()) {
/* skip NOOP node, schedule children right away */ /* skip NOOP node, schedule children right away */
schedule_children(pool, graph, node, layers); schedule_children(pool, graph, node, layers);