From 476e6f0c1bd90c0a62d3d8c6dbf606046f949573 Mon Sep 17 00:00:00 2001 From: Soren Sandmann Date: Sat, 20 Oct 2007 23:51:35 +0000 Subject: [PATCH] Call callback with an extra boolean indicating whether the sample read was 2007-10-20 Soren Sandmann * collector.c (on_read): Call callback with an extra boolean indicating whether the sample read was the first one * collector.c (add_trace_to_stash): Allocate addresses on the stack if possible. * sysprof.c (on_new_sample): Only call update_sensitivity() on the first sample. * stackstash.c (stack_stash_add_trace): Move match to front svn path=/trunk/; revision=373 --- ChangeLog | 13 +++++++++++++ collector.c | 13 ++++++++++--- collector.h | 3 ++- stackstash.c | 16 ++++++++++++---- sysprof.c | 7 +++++-- 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index d22a90a..b215849 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-10-20 Soren Sandmann + + * collector.c (on_read): Call callback with an extra boolean + indicating whether the sample read was the first one + + * collector.c (add_trace_to_stash): Allocate addresses on the + stack if possible. + + * sysprof.c (on_new_sample): Only call update_sensitivity() on the + first sample. + + * stackstash.c (stack_stash_add_trace): Move match to front + 2007-09-16 Soren Sandmann * process.c (process_lookup_kernel_symbol): Add support for diff --git a/collector.c b/collector.c index 9fc207a..46df490 100644 --- a/collector.c +++ b/collector.c @@ -94,11 +94,17 @@ add_trace_to_stash (const SysprofStackTrace *trace, int n_addresses; int n_kernel_words; int a; + gulong addrs_stack[2048]; + int n_alloc; n_addresses = trace->n_addresses; n_kernel_words = trace->n_kernel_words; - addrs = g_new (gulong, n_addresses + n_kernel_words + 2); + n_alloc = n_addresses + n_kernel_words + 2; + if (n_alloc <= 2048) + addrs = addrs_stack; + else + addrs = g_new (gulong, n_alloc); a = 0; /* Add kernel addresses */ @@ -140,7 +146,8 @@ add_trace_to_stash (const SysprofStackTrace *trace, stack_stash_add_trace ( stash, addrs, a, 1); - g_free (addrs); + if (addrs != addrs_stack) + g_free (addrs); } static gboolean @@ -202,7 +209,7 @@ on_read (gpointer data) collector->n_samples++; if (collector->callback) - collector->callback (collector->data); + collector->callback (collector->n_samples == 1, collector->data); } } diff --git a/collector.h b/collector.h index d779723..3f9420d 100644 --- a/collector.h +++ b/collector.h @@ -21,7 +21,8 @@ typedef struct Collector Collector; -typedef void (* CollectorFunc) (gpointer data); +typedef void (* CollectorFunc) (gboolean first_sample, + gpointer data); #define COLLECTOR_ERROR collector_error_quark () diff --git a/stackstash.c b/stackstash.c index 928e637..8490270 100644 --- a/stackstash.c +++ b/stackstash.c @@ -165,13 +165,21 @@ stack_stash_add_trace (StackStash *stash, for (i = n_addrs - 1; i >= 0; --i) { StackNode *match = NULL; - StackNode *n; + StackNode *prev; - for (n = *location; n != NULL; n = n->siblings) + prev = NULL; + for (match = *location; match != NULL; prev = match, match = match->siblings) { - if (n->address == (gpointer)addrs[i]) + if (match->address == (gpointer)addrs[i]) { - match = n; + if (prev) + { + /* move to front */ + prev->siblings = match->siblings; + match->siblings = *location; + *location = match; + } + break; } } diff --git a/sysprof.c b/sysprof.c index aba46c2..c30d05e 100644 --- a/sysprof.c +++ b/sysprof.c @@ -1552,12 +1552,15 @@ build_gui (Application *app) } static void -on_new_sample (gpointer data) +on_new_sample (gboolean first_sample, + gpointer data) { Application *app = data; - if (app->state == PROFILING) + if (app->state == PROFILING && first_sample) update_sensitivity (app); + else + queue_show_samples (app); } static Application * -- 2.7.4