mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
Make this a two-pass algorithm, one pass to add the trace, and one to do
2007-10-22 Soren Sandmann <sandmann@daimi.au.dk> * profile.c (add_trace_to_tree): Make this a two-pass algorithm, one pass to add the trace, and one to do the accounting. svn path=/trunk/; revision=384
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
002f00a950
commit
97076b7d0f
@ -1,3 +1,9 @@
|
|||||||
|
2007-10-22 Soren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
|
* profile.c (add_trace_to_tree): Make this a two-pass
|
||||||
|
algorithm, one pass to add the trace, and one to do the
|
||||||
|
accounting.
|
||||||
|
|
||||||
2007-10-22 Soren Sandmann <sandmann@daimi.au.dk>
|
2007-10-22 Soren Sandmann <sandmann@daimi.au.dk>
|
||||||
|
|
||||||
* sfile.c: Fix some spelling errors
|
* sfile.c: Fix some spelling errors
|
||||||
|
|||||||
26
TODO
26
TODO
@ -156,18 +156,9 @@ Before 1.2:
|
|||||||
- etc.
|
- etc.
|
||||||
done: HEAD will not load files with the wrong inode now.
|
done: HEAD will not load files with the wrong inode now.
|
||||||
|
|
||||||
* In profile.c, change "non_recursive" to "cumulative", and
|
* Consider whether ProfileDescendant can be done with a StackStash We
|
||||||
"marked_non_recursive" to a boolean "charged". This is tricky code,
|
need the "go-back-on-recursion" behavior. That could be added of
|
||||||
so be careful. Possibly make it a two-pass operation:
|
course ... the functions are otherwise very similar.
|
||||||
- first add the new trace
|
|
||||||
- then walk from the leaf, charging nodes
|
|
||||||
That would allow us to get rid of the marked field altogether. In fact,
|
|
||||||
maybe the descendants tree could become a stackstash. We'll just have
|
|
||||||
to make stack_stash_add_trace() return the leaf.
|
|
||||||
Hmm, not quite - we still need the "go-back-on-recursion" behavior.
|
|
||||||
That could be added of course, but that gets complex.
|
|
||||||
|
|
||||||
DONE: the name is now "cumulative"
|
|
||||||
|
|
||||||
* Add spew infrastructure to make remote debugging easier.
|
* Add spew infrastructure to make remote debugging easier.
|
||||||
|
|
||||||
@ -752,6 +743,17 @@ Later:
|
|||||||
|
|
||||||
-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ALREADY DONE: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ALREADY DONE: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||||
|
|
||||||
|
* In profile.c, change "non_recursive" to "cumulative", and
|
||||||
|
"marked_non_recursive" to a boolean "charged". This is tricky code,
|
||||||
|
so be careful. Possibly make it a two-pass operation:
|
||||||
|
- first add the new trace
|
||||||
|
- then walk from the leaf, charging nodes
|
||||||
|
That would allow us to get rid of the marked field altogether. In fact,
|
||||||
|
maybe the descendants tree could become a stackstash. We'll just have
|
||||||
|
to make stack_stash_add_trace() return the leaf.
|
||||||
|
|
||||||
|
DONE: the name is now "cumulative"
|
||||||
|
|
||||||
|
|
||||||
* vdso
|
* vdso
|
||||||
- assume its the same across processes, just look at
|
- assume its the same across processes, just look at
|
||||||
|
|||||||
70
profile.c
70
profile.c
@ -237,21 +237,16 @@ profile_new (StackStash *stash)
|
|||||||
static void
|
static void
|
||||||
add_trace_to_tree (GList *trace, gint size, gpointer data)
|
add_trace_to_tree (GList *trace, gint size, gpointer data)
|
||||||
{
|
{
|
||||||
static GPtrArray *nodes_to_unmark;
|
|
||||||
GList *list;
|
GList *list;
|
||||||
ProfileDescendant *parent = NULL;
|
ProfileDescendant *parent = NULL;
|
||||||
int i, len;
|
ProfileDescendant **tree = data;
|
||||||
ProfileDescendant **tree = data;
|
|
||||||
|
|
||||||
if (!nodes_to_unmark)
|
|
||||||
nodes_to_unmark = g_ptr_array_new ();
|
|
||||||
|
|
||||||
for (list = g_list_last (trace); list != NULL; list = list->prev)
|
for (list = g_list_last (trace); list != NULL; list = list->prev)
|
||||||
{
|
{
|
||||||
gpointer address = list->data;
|
gpointer address = list->data;
|
||||||
ProfileDescendant *match = NULL;
|
|
||||||
ProfileDescendant *prev = NULL;
|
ProfileDescendant *prev = NULL;
|
||||||
|
ProfileDescendant *match = NULL;
|
||||||
|
|
||||||
for (match = *tree; match != NULL; prev = match, match = match->siblings)
|
for (match = *tree; match != NULL; prev = match, match = match->siblings)
|
||||||
{
|
{
|
||||||
if (match->name == address)
|
if (match->name == address)
|
||||||
@ -269,36 +264,11 @@ add_trace_to_tree (GList *trace, gint size, gpointer data)
|
|||||||
|
|
||||||
if (!match)
|
if (!match)
|
||||||
{
|
{
|
||||||
ProfileDescendant *seen_tree_node;
|
|
||||||
ProfileDescendant *n;
|
|
||||||
|
|
||||||
/* Have we seen this object further up the tree? */
|
/* Have we seen this object further up the tree? */
|
||||||
seen_tree_node = NULL;
|
for (match = parent; match != NULL; match = match->parent)
|
||||||
for (n = parent; n != NULL; n = n->parent)
|
|
||||||
{
|
{
|
||||||
if (n->name == address)
|
if (match->name == address)
|
||||||
{
|
|
||||||
seen_tree_node = n;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (seen_tree_node)
|
|
||||||
{
|
|
||||||
ProfileDescendant *node;
|
|
||||||
|
|
||||||
g_assert (parent);
|
|
||||||
|
|
||||||
for (node = parent; node != seen_tree_node->parent; node = node->parent)
|
|
||||||
{
|
|
||||||
node->cumulative -= size;
|
|
||||||
--node->marked_non_recursive;
|
|
||||||
|
|
||||||
g_assert (node->marked_non_recursive == 0 ||
|
|
||||||
node->marked_non_recursive == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
match = seen_tree_node;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,41 +280,21 @@ add_trace_to_tree (GList *trace, gint size, gpointer data)
|
|||||||
match->cumulative = 0;
|
match->cumulative = 0;
|
||||||
match->self = 0;
|
match->self = 0;
|
||||||
match->children = NULL;
|
match->children = NULL;
|
||||||
match->marked_non_recursive = 0;
|
|
||||||
match->parent = parent;
|
match->parent = parent;
|
||||||
match->siblings = *tree;
|
match->siblings = *tree;
|
||||||
*tree = match;
|
*tree = match;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert (match->marked_non_recursive == 0 ||
|
|
||||||
match->marked_non_recursive == 1);
|
|
||||||
|
|
||||||
if (!match->marked_non_recursive)
|
|
||||||
{
|
|
||||||
g_ptr_array_add (nodes_to_unmark, match);
|
|
||||||
match->cumulative += size;
|
|
||||||
++match->marked_non_recursive;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!list->prev)
|
|
||||||
match->self += size;
|
|
||||||
|
|
||||||
tree = &(match->children);
|
tree = &(match->children);
|
||||||
parent = match;
|
parent = match;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = nodes_to_unmark->len;
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
{
|
|
||||||
ProfileDescendant *tree_node = nodes_to_unmark->pdata[i];
|
|
||||||
|
|
||||||
g_assert (tree_node->marked_non_recursive == 0 ||
|
parent->self += size;
|
||||||
tree_node->marked_non_recursive == 1);
|
while (parent)
|
||||||
|
{
|
||||||
tree_node->marked_non_recursive = 0;
|
parent->cumulative += size;
|
||||||
|
parent = parent->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ptr_array_set_size (nodes_to_unmark, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileDescendant *
|
ProfileDescendant *
|
||||||
|
|||||||
@ -47,8 +47,6 @@ struct ProfileDescendant
|
|||||||
ProfileDescendant * parent;
|
ProfileDescendant * parent;
|
||||||
ProfileDescendant * siblings;
|
ProfileDescendant * siblings;
|
||||||
ProfileDescendant * children;
|
ProfileDescendant * children;
|
||||||
|
|
||||||
int marked_non_recursive;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ProfileCaller
|
struct ProfileCaller
|
||||||
|
|||||||
Reference in New Issue
Block a user