Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-12-21 18:14:15 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-12-21 18:33:22 +0300
commit885bb5b137b5ea71869b741e6ee7acc1602ab5c6 (patch)
treec2f6170e2540106681a265a1aeab8b6dab622100 /source/blender/depsgraph/intern/eval/deg_eval.cc
parentd988eae6f983c5ac148786689f75b95c4fa16dee (diff)
Depsgraph: Bring timing statistics to the new dependency graph
This statistics is only collected when debug_value is different from 0. Stored in depsgraph node itself, so we can always have access to average data and other stats which requires persistent storage. This way we also don't waste time trying to find stats from a separately stored hash map.
Diffstat (limited to 'source/blender/depsgraph/intern/eval/deg_eval.cc')
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index c5100856e83..09d25be41d6 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -48,6 +48,7 @@ extern "C" {
#include "atomic_ops.h"
#include "intern/eval/deg_eval_flush.h"
+#include "intern/eval/deg_eval_stats.h"
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_component.h"
#include "intern/nodes/deg_node_id.h"
@@ -74,6 +75,7 @@ struct DepsgraphEvalState {
EvaluationContext *eval_ctx;
Depsgraph *graph;
unsigned int layers;
+ bool do_stats;
};
static void deg_task_run_func(TaskPool *pool,
@@ -86,7 +88,14 @@ static void deg_task_run_func(TaskPool *pool,
/* Sanity checks. */
BLI_assert(!node->is_noop() && "NOOP nodes should not actually be scheduled");
/* Perform operation. */
- node->evaluate(state->eval_ctx);
+ if (state->do_stats) {
+ const double start_time = PIL_check_seconds_timer();
+ node->evaluate(state->eval_ctx);
+ node->stats.current_time += PIL_check_seconds_timer() - start_time;
+ }
+ else {
+ node->evaluate(state->eval_ctx);
+ }
/* Schedule children. */
BLI_task_pool_delayed_push_begin(pool, thread_id);
schedule_children(pool, state->graph, node, state->layers, thread_id);
@@ -145,10 +154,14 @@ static void calculate_pending_parents(Depsgraph *graph, unsigned int layers)
static void initialize_execution(DepsgraphEvalState *state, Depsgraph *graph)
{
+ const bool do_stats = state->do_stats;
calculate_pending_parents(graph, state->layers);
/* Clear tags and other things which needs to be clear. */
foreach (OperationDepsNode *node, graph->operations) {
node->done = 0;
+ if (do_stats) {
+ node->stats.reset_current();
+ }
}
}
@@ -250,6 +263,7 @@ void deg_evaluate_on_refresh(EvaluationContext *eval_ctx,
state.eval_ctx = eval_ctx;
state.graph = graph;
state.layers = layers;
+ state.do_stats = (G.debug_value != 0);
/* Set up task scheduler and pull for threaded evaluation. */
TaskScheduler *task_scheduler;
bool need_free_scheduler;
@@ -268,6 +282,13 @@ void deg_evaluate_on_refresh(EvaluationContext *eval_ctx,
schedule_graph(task_pool, graph, layers);
BLI_task_pool_work_and_wait(task_pool);
BLI_task_pool_free(task_pool);
+ /* Finalize statistics gathering. This is because we only gather single
+ * operation timing here, without aggregating anything to avoid any extra
+ * synchronization.
+ */
+ if (state.do_stats) {
+ deg_eval_stats_aggregate(graph);
+ }
/* Clear any uncleared tags - just in case. */
deg_graph_clear_tags(graph);
if (need_free_scheduler) {