[Bf-blender-cvs] [95acd3b] master: Tweak to early threaded update escape

Sergey Sharybin noreply at git.blender.org
Wed Jan 15 21:09:05 CET 2014


Commit: 95acd3b20a494d083ae2a3d5afa25d5bdf310ac8
Author: Sergey Sharybin
Date:   Thu Jan 16 02:03:48 2014 +0600
https://developer.blender.org/rB95acd3b20a494d083ae2a3d5afa25d5bdf310ac8

Tweak to early threaded update escape

Issue was caused by some objects being in bMain and tagged
for update but not being in the DAG. This means objects
wouldn't be updated and their recalc flag remains untouched
triggering threaded for the next frame.

Solved by tweaking POST_UPDATE_HANDLER_WORKAROUND in the way
that it checks objects' recalc flags from the DAG, not from
the bMain. This will work a bit longer since DAG stored more
nodes than objects in the scene, but this code only runs in
cases when there're some objects tagged for update, which
keeps overall CPU usage on such a workaround pretty low.

Now CPU usage on 11a_comp scene from project Pampa went down
from ~15% down to ~5% (2,69 release uses ~%7).

Pointed by Thomas Dinges in IRC.

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

M	source/blender/blenkernel/BKE_depsgraph.h
M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/blenkernel/intern/scene.c

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

diff --git a/source/blender/blenkernel/BKE_depsgraph.h b/source/blender/blenkernel/BKE_depsgraph.h
index df7e956..bfd0154 100644
--- a/source/blender/blenkernel/BKE_depsgraph.h
+++ b/source/blender/blenkernel/BKE_depsgraph.h
@@ -128,7 +128,7 @@ int  DAG_id_type_tagged(struct Main *bmain, short idtype);
 void DAG_scene_flush_update(struct Main *bmain, struct Scene *sce, unsigned int lay, const short do_time);
 void DAG_ids_flush_tagged(struct Main *bmain);
 void DAG_ids_check_recalc(struct Main *bmain, struct Scene *scene, int time);
-void DAG_ids_clear_recalc(struct Main *bmain);
+void DAG_ids_clear_recalc(struct Main *bmain, struct Scene *scene);
 
 /* Armature: sorts the bones according to dependencies between them */
 
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 1c36ccc..b9c9572 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2471,7 +2471,7 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time)
 
 #define POST_UPDATE_HANDLER_WORKAROUND
 
-void DAG_ids_clear_recalc(Main *bmain)
+void DAG_ids_clear_recalc(Main *bmain, Scene *scene)
 {
 	ListBase *lbarray[MAX_LIBARRAY];
 	bNodeTree *ntree;
@@ -2479,6 +2479,21 @@ void DAG_ids_clear_recalc(Main *bmain)
 
 #ifdef POST_UPDATE_HANDLER_WORKAROUND
 	bool have_updated_objects = false;
+
+	if (DAG_id_type_tagged(bmain, ID_OB)) {
+		DagNode *node;
+		for (node = scene->theDag->DagNode.first; node; node = node->next) {
+			if (node->type == ID_OB) {
+				Object *object = (Object *) node->ob;
+				if (object->recalc & OB_RECALC_ALL) {
+					have_updated_objects = true;
+					break;
+				}
+			}
+		}
+	}
+#else
+	(void) scene;  /* Unused. */
 #endif
 
 	/* loop over all ID types */
@@ -2495,15 +2510,6 @@ void DAG_ids_clear_recalc(Main *bmain)
 				if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA))
 					id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA);
 
-#ifdef POST_UPDATE_HANDLER_WORKAROUND
-				if (GS(id->name) == ID_OB) {
-					Object *object = (Object *) id;
-					if (object->recalc & OB_RECALC_ALL) {
-						have_updated_objects = true;
-					}
-				}
-#endif
-
 				/* some ID's contain semi-datablock nodetree */
 				ntree = ntreeFromID(id);
 				if (ntree && (ntree->id.flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)))
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index c6a2dfb..8b38660 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1563,7 +1563,7 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
 	DAG_ids_check_recalc(bmain, scene, FALSE);
 
 	/* clear recalc flags */
-	DAG_ids_clear_recalc(bmain);
+	DAG_ids_clear_recalc(bmain, scene);
 }
 
 /* applies changes right away, does all sets too */
@@ -1639,7 +1639,7 @@ void BKE_scene_update_for_newframe(EvaluationContext *eval_ctx, Main *bmain, Sce
 	DAG_ids_check_recalc(bmain, sce, TRUE);
 
 	/* clear recalc flags */
-	DAG_ids_clear_recalc(bmain);
+	DAG_ids_clear_recalc(bmain, sce);
 
 #ifdef DETAILED_ANALYSIS_OUTPUT
 	fprintf(stderr, "frame update start_time %f duration %f\n", start_time, PIL_check_seconds_timer() - start_time);




More information about the Bf-blender-cvs mailing list