[Bf-blender-cvs] [96d74919f49] uuid-undo-experiments: Some more debug prints to try to understand the new undo slowness.

Bastien Montagne noreply at git.blender.org
Thu Mar 26 09:59:06 CET 2020


Commit: 96d74919f49f4368f5dca3613da214f053dcd09d
Author: Bastien Montagne
Date:   Thu Mar 26 09:56:34 2020 +0100
Branches: uuid-undo-experiments
https://developer.blender.org/rB96d74919f49f4368f5dca3613da214f053dcd09d

Some more debug prints to try to understand the new undo slowness.

Suspect this has to do with the recalc tags mostly, but still do not
really understand the issue...

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

M	source/blender/blenkernel/intern/undo_system.c
M	source/blender/blenloader/intern/readfile.c

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

diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 6d484a7b702..329fb843a40 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -660,6 +660,8 @@ bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack,
                                         UndoStep *us,
                                         bool use_skip)
 {
+  printf("\n\nINIT UNDO STEP\n");
+  BKE_undosys_print(ustack);
   UNDO_NESTED_ASSERT(false);
   if (us) {
     undosys_stack_validate(ustack, true);
@@ -711,8 +713,12 @@ bool BKE_undosys_step_undo_with_data_ex(UndoStack *ustack,
       } while ((us_active != us_iter) && (us_iter = us_iter->prev));
     }
 
+    printf("\n\nEND UNDO STEP\n");
+    BKE_undosys_print(ustack);
     return true;
   }
+  printf("\n\nEND UNDO STEP\n");
+  BKE_undosys_print(ustack);
   return false;
 }
 bool BKE_undosys_step_undo_with_data(UndoStack *ustack, bContext *C, UndoStep *us)
@@ -737,6 +743,8 @@ bool BKE_undosys_step_redo_with_data_ex(UndoStack *ustack,
                                         UndoStep *us,
                                         bool use_skip)
 {
+  printf("\n\nINIT REDO STEP\n");
+  BKE_undosys_print(ustack);
   UNDO_NESTED_ASSERT(false);
   UndoStep *us_next = us ? us->next : NULL;
   /* Unlike undo accumulate, we always use the next. */
@@ -777,8 +785,12 @@ bool BKE_undosys_step_redo_with_data_ex(UndoStack *ustack,
         ustack->step_active = us_iter;
       } while ((us_active != us_iter) && (us_iter = us_iter->next));
     }
+    printf("\n\nEND REDO STEP\n");
+    BKE_undosys_print(ustack);
     return true;
   }
+  printf("\n\nEND REDO STEP\n");
+  BKE_undosys_print(ustack);
   return false;
 }
 bool BKE_undosys_step_redo_with_data(UndoStack *ustack, bContext *C, UndoStep *us)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index eb787a16387..e0c0d56e841 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -238,7 +238,7 @@
 #define USE_GHASH_RESTORE_POINTER
 
 /* Define this to have verbose debug prints. */
-//#define USE_DEBUG_PRINT
+#define USE_DEBUG_PRINT
 
 #ifdef USE_DEBUG_PRINT
 #  define DEBUG_PRINTF(...) printf(__VA_ARGS__)
@@ -9357,8 +9357,9 @@ static BHead *read_libblock(FileData *fd,
        * and evaluate, not actual file reading. */
       bhead = read_data_into_oldnewmap(fd, id_bhead, allocname);
 
-      DEBUG_PRINTF(
-          "%s: ID %s is unchanged: %d\n", __func__, id->name, fd->are_memchunks_identical);
+      if (ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT))
+        DEBUG_PRINTF(
+            "%s: ID %s is unchanged: %d\n", __func__, id->name, fd->are_memchunks_identical);
 
       if (fd->memfile != NULL) {
         BLI_assert(fd->old_idmap != NULL || !do_partial_undo);
@@ -9367,13 +9368,37 @@ static BHead *read_libblock(FileData *fd,
 
         /* Find the 'current' existing ID we want to reuse instead of the one we would read from
          * the undo memfile. */
-        DEBUG_PRINTF("\t Looking for ID %s with uuid %u instead of newly read one\n",
-                     id->name,
-                     id->session_uuid);
+        if (ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT))
+          DEBUG_PRINTF("\t Looking for ID %s with uuid %u instead of newly read one\n",
+                       id->name,
+                       id->session_uuid);
         id_old = do_partial_undo ? BKE_main_idmap_lookup_uuid(fd->old_idmap, id->session_uuid) :
                                    NULL;
         bool can_finalize_and_return = false;
 
+        if (id_old != NULL &&
+            ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT)) {
+          DEBUG_PRINTF("\t\t\tRecalc: read | existing\n");
+          DEBUG_PRINTF("\t\t\tCOW   :   %d  | %d\n",
+                       (id->recalc_undo_accumulated & ID_RECALC_COPY_ON_WRITE) != 0,
+                       (id_old->recalc_undo_accumulated & ID_RECALC_COPY_ON_WRITE) != 0);
+          DEBUG_PRINTF("\t\t\tTransf:   %d  | %d\n",
+                       (id->recalc_undo_accumulated & ID_RECALC_TRANSFORM) != 0,
+                       (id_old->recalc_undo_accumulated & ID_RECALC_TRANSFORM) != 0);
+          DEBUG_PRINTF("\t\t\tGeom  :   %d  | %d\n",
+                       (id->recalc_undo_accumulated & ID_RECALC_GEOMETRY) != 0,
+                       (id_old->recalc_undo_accumulated & ID_RECALC_GEOMETRY) != 0);
+          DEBUG_PRINTF("\t\t\tAnim  :   %d  | %d\n",
+                       (id->recalc_undo_accumulated & ID_RECALC_ANIMATION) != 0,
+                       (id_old->recalc_undo_accumulated & ID_RECALC_ANIMATION) != 0);
+          DEBUG_PRINTF("\t\t\tShade :   %d  | %d\n",
+                       (id->recalc_undo_accumulated & ID_RECALC_SHADING) != 0,
+                       (id_old->recalc_undo_accumulated & ID_RECALC_SHADING) != 0);
+          DEBUG_PRINTF("\t\t\tSel   :   %d  | %d\n",
+                       (id->recalc_undo_accumulated & ID_RECALC_SELECT) != 0,
+                       (id_old->recalc_undo_accumulated & ID_RECALC_SELECT) != 0);
+        }
+
         if (ELEM(idcode, ID_WM, ID_SCR, ID_WS)) {
           /* Read WindowManager, Screen and WorkSpace IDs are never actually used during undo (see
            * `setup_app_data()` in `blendfile.c`).
@@ -9406,7 +9431,8 @@ static BHead *read_libblock(FileData *fd,
         }
 
         if (can_finalize_and_return) {
-          DEBUG_PRINTF("Re-using existing ID %s instead of newly read one\n", id_old->name);
+          if (ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT))
+            DEBUG_PRINTF("Re-using existing ID %s instead of newly read one\n", id_old->name);
           oldnewmap_insert(fd->libmap, id_bhead->old, id_old, id_bhead->code);
           oldnewmap_insert(fd->libmap, id_old, id_old, id_bhead->code);
 
@@ -9438,6 +9464,8 @@ static BHead *read_libblock(FileData *fd,
              * actually perform a depsgraph update, otherwise we'd only ever use the flags from one
              * of the steps, and never get proper flags matching all others. */
             id_old->recalc_undo_accumulated |= id->recalc_undo_accumulated;
+
+            id_old->recalc &= ~(ID_RECALC_COPY_ON_WRITE);
           }
 
           MEM_freeN(id);
@@ -9456,9 +9484,10 @@ static BHead *read_libblock(FileData *fd,
        * addresses for those as well. */
       if (fd->memfile != NULL && do_partial_undo && id->lib == NULL) {
         BLI_assert(fd->old_idmap != NULL);
-        DEBUG_PRINTF("\t Looking for ID %s with uuid %u instead of newly read one\n",
-                     id->name,
-                     id->session_uuid);
+        if (ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT))
+          DEBUG_PRINTF("\t Looking for ID %s with uuid %u instead of newly read one\n",
+                       id->name,
+                       id->session_uuid);
         id_old = BKE_main_idmap_lookup_uuid(fd->old_idmap, id->session_uuid);
         if (id_old != NULL) {
           BLI_assert(MEM_allocN_len(id) == MEM_allocN_len(id_old));
@@ -9474,10 +9503,12 @@ static BHead *read_libblock(FileData *fd,
       /* At this point, we know we are going to keep that newly read & allocated ID, so we need to
        * reallocate it to ensure we actually get a unique memory address for it. */
       if (!do_id_swap) {
-        DEBUG_PRINTF("using newly-read ID %s to a new mem address\n", id->name);
+        if (ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT))
+          DEBUG_PRINTF("using newly-read ID %s to a new mem address\n", id->name);
       }
       else {
-        DEBUG_PRINTF("using newly-read ID %s to its old, already existing address\n", id->name);
+        if (ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT))
+          DEBUG_PRINTF("using newly-read ID %s to its old, already existing address\n", id->name);
       }
 
       /* for ID_LINK_PLACEHOLDER check */
@@ -9699,10 +9730,11 @@ static BHead *read_libblock(FileData *fd,
     BLI_addtail(old_lb, id);
   }
   else if (fd->memfile != NULL) {
-    DEBUG_PRINTF("We had to fully re-recreate ID %s (old addr: %p, new addr: %p)...\n",
-                 id->name,
-                 id_old,
-                 id);
+    if (ELEM(GS(id->name), ID_SCE, ID_OB, ID_ME, ID_LA, ID_CA, ID_GR, ID_MA, ID_TE, ID_NT))
+      DEBUG_PRINTF("We had to fully re-recreate ID %s (old addr: %p, new addr: %p)...\n",
+                   id->name,
+                   id_old,
+                   id);
   }
 
   return (bhead);



More information about the Bf-blender-cvs mailing list