Depsgraph: Remove bunch of debug code

Was never actually used and implementation seems to be slow: we shouldn't be
doing per-node evaluation hash lookups, adds too much overhead. We can instead
store statistics in the node itself, and maybe even group them somehow.

Ideally such a statistics should be user-friendly so riggers and animators
can see exactly what's happening.
This commit is contained in:
2017-10-24 16:00:50 +02:00
parent 2103194f79
commit f29ff14d6e
6 changed files with 1 additions and 392 deletions

View File

@@ -53,7 +53,6 @@ set(SRC
intern/builder/deg_builder_transitive.cc
intern/debug/deg_debug_graphviz.cc
intern/eval/deg_eval.cc
intern/eval/deg_eval_debug.cc
intern/eval/deg_eval_flush.cc
intern/nodes/deg_node.cc
intern/nodes/deg_node_component.cc
@@ -78,7 +77,6 @@ set(SRC
intern/builder/deg_builder_relations.h
intern/builder/deg_builder_transitive.h
intern/eval/deg_eval.h
intern/eval/deg_eval_debug.h
intern/eval/deg_eval_flush.h
intern/nodes/deg_node.h
intern/nodes/deg_node_component.h

View File

@@ -39,45 +39,11 @@
extern "C" {
#endif
struct GHash;
struct ID;
struct Depsgraph;
/* ************************************************ */
/* Statistics */
typedef struct DepsgraphStatsTimes {
float duration_last;
} DepsgraphStatsTimes;
typedef struct DepsgraphStatsComponent {
struct DepsgraphStatsComponent *next, *prev;
char name[64];
DepsgraphStatsTimes times;
} DepsgraphStatsComponent;
typedef struct DepsgraphStatsID {
struct ID *id;
DepsgraphStatsTimes times;
ListBase components;
} DepsgraphStatsID;
typedef struct DepsgraphStats {
struct GHash *id_stats;
} DepsgraphStats;
struct DepsgraphStats *DEG_stats(void);
void DEG_stats_verify(void);
struct DepsgraphStatsID *DEG_stats_id(struct ID *id);
/* ------------------------------------------------ */
void DEG_stats_simple(const struct Depsgraph *graph,
void DEG_stats_simple(const struct Depsgraph *graph,
size_t *r_outer,
size_t *r_operations,
size_t *r_relations);

View File

@@ -41,30 +41,9 @@ extern "C" {
#include "DEG_depsgraph_debug.h"
#include "DEG_depsgraph_build.h"
#include "intern/eval/deg_eval_debug.h"
#include "intern/depsgraph_intern.h"
#include "util/deg_util_foreach.h"
/* ************************************************ */
DepsgraphStats *DEG_stats(void)
{
return DEG::DepsgraphDebug::stats;
}
void DEG_stats_verify()
{
DEG::DepsgraphDebug::verify_stats();
}
DepsgraphStatsID *DEG_stats_id(ID *id)
{
if (!DEG::DepsgraphDebug::stats) {
return NULL;
}
return DEG::DepsgraphDebug::get_id_stats(id, false);
}
bool DEG_debug_compare(const struct Depsgraph *graph1,
const struct Depsgraph *graph2)
{

View File

@@ -47,7 +47,6 @@ extern "C" {
#include "atomic_ops.h"
#include "intern/eval/deg_eval_debug.h"
#include "intern/eval/deg_eval_flush.h"
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_component.h"
@@ -341,15 +340,11 @@ void deg_evaluate_on_refresh(EvaluationContext *eval_ctx,
}
#endif
DepsgraphDebug::eval_begin(eval_ctx);
schedule_graph(task_pool, graph, layers);
BLI_task_pool_work_and_wait(task_pool);
BLI_task_pool_free(task_pool);
DepsgraphDebug::eval_end(eval_ctx);
/* Clear any uncleared tags - just in case. */
deg_graph_clear_tags(graph);

View File

@@ -1,250 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2014 Blender Foundation.
* All rights reserved.
*
* Original Author: Lukas Toenne
* Contributor(s): None Yet
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/depsgraph/intern/eval/deg_eval_debug.cc
* \ingroup depsgraph
*
* Implementation of tools for debugging the depsgraph
*/
#include "intern/eval/deg_eval_debug.h"
#include <cstring> /* required for STREQ later on. */
#include "BLI_listbase.h"
#include "BLI_ghash.h"
extern "C" {
#include "WM_api.h"
#include "WM_types.h"
} /* extern "C" */
#include "DEG_depsgraph_debug.h"
#include "intern/nodes/deg_node.h"
#include "intern/nodes/deg_node_component.h"
#include "intern/nodes/deg_node_operation.h"
#include "intern/depsgraph_intern.h"
namespace DEG {
DepsgraphStats *DepsgraphDebug::stats = NULL;
static string get_component_name(eDepsNode_Type type, const char *name = "")
{
DepsNodeFactory *factory = deg_get_node_factory(type);
if (name[0] != '\0') {
return string(factory->tname());
}
else {
return string(factory->tname()) + " | " + name;
}
}
static void times_clear(DepsgraphStatsTimes &times)
{
times.duration_last = 0.0f;
}
static void times_add(DepsgraphStatsTimes &times, float time)
{
times.duration_last += time;
}
void DepsgraphDebug::eval_begin(const EvaluationContext *UNUSED(eval_ctx))
{
/* TODO(sergey): Stats are currently globally disabled. */
/* verify_stats(); */
reset_stats();
}
void DepsgraphDebug::eval_end(const EvaluationContext *UNUSED(eval_ctx))
{
WM_main_add_notifier(NC_SPACE | ND_SPACE_INFO_REPORT, NULL);
}
void DepsgraphDebug::eval_step(const EvaluationContext *UNUSED(eval_ctx),
const char *message)
{
#ifdef DEG_DEBUG_BUILD
if (deg_debug_eval_cb)
deg_debug_eval_cb(deg_debug_eval_userdata, message);
#else
(void)message; /* Ignored. */
#endif
}
void DepsgraphDebug::task_started(Depsgraph *graph,
const OperationDepsNode *node)
{
if (stats) {
BLI_spin_lock(&graph->lock);
ComponentDepsNode *comp = node->owner;
ID *id = comp->owner->id;
DepsgraphStatsID *id_stats = get_id_stats(id, true);
times_clear(id_stats->times);
/* XXX TODO use something like: if (id->flag & ID_DEG_DETAILS) {...} */
if (0) {
/* XXX component name usage needs cleanup! currently mixes identifier
* and description strings!
*/
DepsgraphStatsComponent *comp_stats =
get_component_stats(id, get_component_name(comp->type,
comp->name).c_str(),
true);
times_clear(comp_stats->times);
}
BLI_spin_unlock(&graph->lock);
}
}
void DepsgraphDebug::task_completed(Depsgraph *graph,
const OperationDepsNode *node,
double time)
{
if (stats) {
BLI_spin_lock(&graph->lock);
ComponentDepsNode *comp = node->owner;
ID *id = comp->owner->id;
DepsgraphStatsID *id_stats = get_id_stats(id, true);
times_add(id_stats->times, time);
/* XXX TODO use something like: if (id->flag & ID_DEG_DETAILS) {...} */
if (0) {
/* XXX component name usage needs cleanup! currently mixes identifier
* and description strings!
*/
DepsgraphStatsComponent *comp_stats =
get_component_stats(id,
get_component_name(comp->type,
comp->name).c_str(),
true);
times_add(comp_stats->times, time);
}
BLI_spin_unlock(&graph->lock);
}
}
/* ********** */
/* Statistics */
/* GHash callback */
static void deg_id_stats_free(void *val)
{
DepsgraphStatsID *id_stats = (DepsgraphStatsID *)val;
if (id_stats) {
BLI_freelistN(&id_stats->components);
MEM_freeN(id_stats);
}
}
void DepsgraphDebug::stats_init()
{
if (!stats) {
stats = (DepsgraphStats *)MEM_callocN(sizeof(DepsgraphStats),
"Depsgraph Stats");
stats->id_stats = BLI_ghash_new(BLI_ghashutil_ptrhash,
BLI_ghashutil_ptrcmp,
"Depsgraph ID Stats Hash");
}
}
void DepsgraphDebug::stats_free()
{
if (stats) {
BLI_ghash_free(stats->id_stats, NULL, deg_id_stats_free);
MEM_freeN(stats);
stats = NULL;
}
}
void DepsgraphDebug::verify_stats()
{
stats_init();
}
void DepsgraphDebug::reset_stats()
{
if (!stats) {
return;
}
/* XXX this doesn't work, will immediately clear all info,
* since most depsgraph updates have none or very few updates to handle.
*
* Could consider clearing only zero-user ID blocks here
*/
// BLI_ghash_clear(stats->id_stats, NULL, deg_id_stats_free);
}
DepsgraphStatsID *DepsgraphDebug::get_id_stats(ID *id, bool create)
{
DepsgraphStatsID *id_stats = (DepsgraphStatsID *)BLI_ghash_lookup(stats->id_stats, id);
if (!id_stats && create) {
id_stats = (DepsgraphStatsID *)MEM_callocN(sizeof(DepsgraphStatsID),
"Depsgraph ID Stats");
id_stats->id = id;
BLI_ghash_insert(stats->id_stats, id, id_stats);
}
return id_stats;
}
DepsgraphStatsComponent *DepsgraphDebug::get_component_stats(
DepsgraphStatsID *id_stats,
const char *name,
bool create)
{
DepsgraphStatsComponent *comp_stats;
for (comp_stats = (DepsgraphStatsComponent *)id_stats->components.first;
comp_stats != NULL;
comp_stats = comp_stats->next)
{
if (STREQ(comp_stats->name, name)) {
break;
}
}
if (!comp_stats && create) {
comp_stats = (DepsgraphStatsComponent *)MEM_callocN(sizeof(DepsgraphStatsComponent),
"Depsgraph Component Stats");
BLI_strncpy(comp_stats->name, name, sizeof(comp_stats->name));
BLI_addtail(&id_stats->components, comp_stats);
}
return comp_stats;
}
} // namespace DEG

View File

@@ -1,79 +0,0 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2013 Blender Foundation.
* All rights reserved.
*
* Original Author: Joshua Leung
* Contributor(s): None Yet
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/depsgraph/intern/eval/deg_eval_debug.h
* \ingroup depsgraph
*/
#pragma once
#include "intern/depsgraph_types.h"
struct ID;
struct EvaluationContext;
struct DepsgraphStats;
struct DepsgraphStatsID;
struct DepsgraphStatsComponent;
namespace DEG {
struct Depsgraph;
struct DepsgraphSettings;
struct OperationDepsNode;
struct DepsgraphDebug {
static DepsgraphStats *stats;
static void stats_init();
static void stats_free();
static void verify_stats();
static void reset_stats();
static void eval_begin(const EvaluationContext *eval_ctx);
static void eval_end(const EvaluationContext *eval_ctx);
static void eval_step(const EvaluationContext *eval_ctx,
const char *message);
static void task_started(Depsgraph *graph, const OperationDepsNode *node);
static void task_completed(Depsgraph *graph,
const OperationDepsNode *node,
double time);
static DepsgraphStatsID *get_id_stats(ID *id, bool create);
static DepsgraphStatsComponent *get_component_stats(DepsgraphStatsID *id_stats,
const char *name,
bool create);
static DepsgraphStatsComponent *get_component_stats(ID *id,
const char *name,
bool create)
{
return get_component_stats(get_id_stats(id, create), name, create);
}
};
} // namespace DEG