Add command-line option to not do liboverride autoresync on fileload.

The new --disable-liboverride-auto-resync commandline option will prevent
running liboverride auto-resync immediately after loading a blendfile.

This is an alternative way to setting the User Preferences Debug option
`No Override Auto Resync`.

-------

Some quick performances tests:
Loading a Gold production file goes from 26.5s to 25.9s.

Combined with the recent `--disable-depsgraph-on-file-load` option, it
goes from 3.5s to 2.9s, so another nice extra 15% speedup when only
bare-metal blendfile loading is needed.

Pull Request: https://projects.blender.org/blender/blender/pulls/132017
This commit is contained in:
Bastien Montagne
2024-12-17 18:59:49 +01:00
committed by Bastien Montagne
parent 94120967e7
commit ef0fcab8b7
7 changed files with 52 additions and 6 deletions

View File

@@ -292,6 +292,14 @@ enum {
*/
G_BACKGROUND_NO_DEPSGRAPH = 1 << 2,
/**
* Do not perform automatic resync of library overrides on blendfile load.
*
* NOTE: runtime version of #UserDef_Experimental.no_override_auto_resync, both values are OR'ed
* together.
*/
G_LIBOVERRIDE_NO_AUTO_RESYNC = 1 << 3,
// G_FILE_DEPRECATED_9 = (1 << 9),
G_FILE_NO_UI = (1 << 10),
@@ -330,7 +338,8 @@ enum {
* This means we can change the values without worrying about do-versions.
*/
#define G_FILE_FLAG_ALL_RUNTIME \
(G_BACKGROUND_NO_DEPSGRAPH | G_FILE_NO_UI | G_FILE_RECOVER_READ | G_FILE_RECOVER_WRITE)
(G_BACKGROUND_NO_DEPSGRAPH | G_LIBOVERRIDE_NO_AUTO_RESYNC | G_FILE_NO_UI | \
G_FILE_RECOVER_READ | G_FILE_RECOVER_WRITE)
/** #Global.moving, signals drawing in (3d) window to denote transform */
enum {

View File

@@ -40,6 +40,12 @@ struct ReportList;
struct Scene;
struct ViewLayer;
namespace blender::bke::liboverride {
bool is_auto_resync_enabled();
} // namespace blender::bke::liboverride
/**
* Initialize empty overriding of \a reference_id by \a local_id.
*/

View File

@@ -1202,7 +1202,7 @@ static void setup_app_data(bContext *C,
BLI_assert(BKE_main_namemap_validate(bmain));
if (mode != LOAD_UNDO && !USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync)) {
if (mode != LOAD_UNDO && liboverride::is_auto_resync_enabled()) {
reports->duration.lib_overrides_resync = BLI_time_now_seconds();
BKE_lib_override_library_main_resync(

View File

@@ -64,6 +64,8 @@
static CLG_LogRef LOG = {"bke.blendfile_link_append"};
using namespace blender::bke;
/* -------------------------------------------------------------------- */
/** \name Link/append context implementation and public management API.
* \{ */
@@ -1997,9 +1999,7 @@ void BKE_blendfile_library_relocate(BlendfileLinkAppendContext *lapp_context,
BKE_library_main_rebuild_hierarchy(bmain);
/* Resync overrides if needed. */
if (!USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync) &&
lapp_context->params->context.scene != nullptr)
{
if (liboverride::is_auto_resync_enabled() && lapp_context->params->context.scene != nullptr) {
BlendFileReadReport report{};
report.reports = reports;
BKE_lib_override_library_main_resync(bmain,

View File

@@ -77,6 +77,16 @@ using namespace blender::bke;
static CLG_LogRef LOG = {"bke.liboverride"};
static CLG_LogRef LOG_RESYNC = {"bke.liboverride_resync"};
namespace blender::bke::liboverride {
bool is_auto_resync_enabled()
{
return !USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync) &&
(G.fileflags & G_LIBOVERRIDE_NO_AUTO_RESYNC) == 0;
}
} // namespace blender::bke::liboverride
static void lib_override_library_property_copy(IDOverrideLibraryProperty *op_dst,
IDOverrideLibraryProperty *op_src);
static void lib_override_library_property_operation_copy(

View File

@@ -7510,7 +7510,8 @@ static void rna_def_userdef_experimental(BlenderRNA *brna)
RNA_def_property_ui_text(prop,
"No Override Auto Resync",
"Disable library overrides automatic resync detection and process on "
"file load (can be useful to help fixing broken files)");
"file load (can be useful to help fixing broken files). Also see the "
"`--disable-liboverride-auto-resync` command line option");
prop = RNA_def_property(srna, "use_new_point_cloud_type", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "use_new_point_cloud_type", 1);

View File

@@ -1124,6 +1124,20 @@ static int arg_handle_disable_depsgraph_on_file_load(int /*argc*/,
return 0;
}
static const char arg_handle_disable_liboverride_auto_resync_doc[] =
"\n"
"\tDo not perform library override automatic resync when loading a new blendfile.\n"
"\n"
"\tNOTE: this is an alternative way to get the same effect as when setting the\n"
"\t`No Override Auto Resync` User Preferences Debug option.";
static int arg_handle_disable_liboverride_auto_resync(int /*argc*/,
const char ** /*argv*/,
void * /*data*/)
{
G.fileflags |= G_LIBOVERRIDE_NO_AUTO_RESYNC;
return 0;
}
static const char arg_handle_log_level_set_doc[] =
"<level>\n"
"\tSet the logging verbosity level (higher for more details) defaults to 1,\n"
@@ -2693,6 +2707,12 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
CB(arg_handle_disable_depsgraph_on_file_load),
nullptr);
BLI_args_add(ba,
nullptr,
"--disable-liboverride-auto-resync",
CB(arg_handle_disable_liboverride_auto_resync),
nullptr);
BLI_args_add(ba, "-a", nullptr, CB(arg_handle_playback_mode), nullptr);
BLI_args_add(ba, "-d", "--debug", CB(arg_handle_debug_mode_set), ba);