[Bf-blender-cvs] [f6b23c63e1d] master: LibOverride: Parallelize diffing of Main database.

Bastien Montagne noreply at git.blender.org
Fri Jun 19 17:01:26 CEST 2020


Commit: f6b23c63e1d7aae45ac97b92d4b57d550c6051bc
Author: Bastien Montagne
Date:   Fri Jun 19 16:55:24 2020 +0200
Branches: master
https://developer.blender.org/rBf6b23c63e1d7aae45ac97b92d4b57d550c6051bc

LibOverride: Parallelize diffing of Main database.

This will not give any noticeable improvements in common editing tasks,
since then usually only a very few IDs are changed and checked for
override updates.

However, it makes full override diffing process several times faster
(happens usually when saving a .blend file, but could also help e.g.
when multi-editing several override objects at the same time...).

===================================================================

M	source/blender/blenkernel/intern/lib_override.c

===================================================================

diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 64ed41e3a08..28d8b5932a1 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -40,6 +40,7 @@
 #include "BLI_ghash.h"
 #include "BLI_listbase.h"
 #include "BLI_string.h"
+#include "BLI_task.h"
 #include "BLI_utildefines.h"
 
 #include "RNA_access.h"
@@ -796,6 +797,14 @@ bool BKE_lib_override_library_operations_create(Main *bmain,
   return ret;
 }
 
+static void lib_override_library_operations_create_cb(TaskPool *__restrict pool, void *taskdata)
+{
+  Main *bmain = BLI_task_pool_user_data(pool);
+  ID *id = taskdata;
+
+  BKE_lib_override_library_operations_create(bmain, id, false);
+}
+
 /** Check all overrides from given \a bmain and create/update overriding operations as needed. */
 void BKE_lib_override_library_main_operations_create(Main *bmain, const bool force_auto)
 {
@@ -811,15 +820,21 @@ void BKE_lib_override_library_main_operations_create(Main *bmain, const bool for
     BKE_lib_override_library_main_tag(bmain, IDOVERRIDE_LIBRARY_TAG_UNUSED, true);
   }
 
+  TaskPool *task_pool = BLI_task_pool_create(bmain, TASK_PRIORITY_HIGH);
+
   FOREACH_MAIN_ID_BEGIN (bmain, id) {
     if ((ID_IS_OVERRIDE_LIBRARY(id) && force_auto) ||
         (id->tag & LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH)) {
-      BKE_lib_override_library_operations_create(bmain, id, force_auto);
+      BLI_task_pool_push(task_pool, lib_override_library_operations_create_cb, id, false, NULL);
       id->tag &= ~LIB_TAG_OVERRIDE_LIBRARY_AUTOREFRESH;
     }
   }
   FOREACH_MAIN_ID_END;
 
+  BLI_task_pool_work_and_wait(task_pool);
+
+  BLI_task_pool_free(task_pool);
+
   if (force_auto) {
     BKE_lib_override_library_main_unused_cleanup(bmain);
   }



More information about the Bf-blender-cvs mailing list