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...).
This commit is contained in:
Bastien Montagne 2020-06-19 16:55:24 +02:00
parent 9905f5725c
commit f6b23c63e1
1 changed files with 16 additions and 1 deletions

View File

@ -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);
}