From d78e744422dbaed05356b775e43846f89ac09e36 Mon Sep 17 00:00:00 2001 From: Soren Sandmann Date: Thu, 26 Oct 2006 05:13:16 +0000 Subject: [PATCH] Make the pointer array static to improve cache behavior and reduce calls 2006-10-25 Soren Sandmann * profile.c (add_trace_to_tree): Make the pointer array static to improve cache behavior and reduce calls to malloc(). * process.c (lookup_kernel_symbol): Remove obsolete comment. --- ChangeLog | 7 +++++++ TODO | 5 ++++- process.c | 13 +------------ profile.c | 7 +++++-- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c814769..10c2a9a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-10-25 Soren Sandmann + + * profile.c (add_trace_to_tree): Make the pointer array static to + improve cache behavior and reduce calls to malloc(). + + * process.c (lookup_kernel_symbol): Remove obsolete comment. + 2006-10-25 Soren Sandmann * process.c (free_maps): Take a pointer to a variable that will be diff --git a/TODO b/TODO index 8ab57dbf..8267beb9 100644 --- a/TODO +++ b/TODO @@ -433,7 +433,10 @@ http://www.linuxbase.org/spec/booksets/LSB-Embedded/LSB-Embedded/ehframe.html - Have kernel module report the file the address was found in Should avoid a lot of potential broken/raciness with dlopen etc. - Probably better to send a list of maps with each trace. + Probably better to send a list of maps with each trace. Which + shouldn't really be that expensive. We already walk the list of + maps in process_ensure_map() on every trace. And we can do hashing + if it turns out to be a problem. - Figure out how Google's pprof script works. Then add real call graph drawing. (google's script is really simple; uses dot from graphviz). diff --git a/process.c b/process.c index 40f85e1e..a33173e9 100644 --- a/process.c +++ b/process.c @@ -424,8 +424,6 @@ file_exists (const char *name) int fd; fd = open (name, O_RDONLY); - g_print ("trying: %s\n", name); - if (fd > 0) { close (fd); @@ -565,16 +563,7 @@ lookup_kernel_symbol (gulong address) { static const char *const kernel = "In kernel"; -#if 0 - g_print ("kernel binary: %s\n", find_kernel_binary ()); -#endif - - return kernel; /* Can we just return "In kernel"? */ -#if 0 - kernel.name = "In kernel"; - kernel.address = 0x00001337; - return &kernel; -#endif + return kernel; } const char * diff --git a/profile.c b/profile.c index 531ea646..3c0b2c9b 100644 --- a/profile.c +++ b/profile.c @@ -243,12 +243,15 @@ profile_new (StackStash *stash) static void add_trace_to_tree (GList *trace, gint size, gpointer data) { + static GPtrArray *nodes_to_unmark; GList *list; - GPtrArray *nodes_to_unmark = g_ptr_array_new (); ProfileDescendant *parent = NULL; int i, len; 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) { gpointer address = list->data; @@ -325,7 +328,7 @@ add_trace_to_tree (GList *trace, gint size, gpointer data) tree_node->marked_non_recursive = 0; } - g_ptr_array_free (nodes_to_unmark, TRUE); + g_ptr_array_set_size (nodes_to_unmark, 0); } ProfileDescendant *