Call callback with an extra boolean indicating whether the sample read was
authorSoren Sandmann <sandmann@daimi.au.dk>
Sat, 20 Oct 2007 23:51:35 +0000 (23:51 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Sat, 20 Oct 2007 23:51:35 +0000 (23:51 +0000)
2007-10-20  Soren Sandmann <sandmann@daimi.au.dk>

       * 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
collector.c
collector.h
stackstash.c
sysprof.c

index d22a90a..b215849 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-10-20  Soren Sandmann <sandmann@daimi.au.dk>
+
+       * 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 <sandmann@daimi.au.dk>
 
        * process.c (process_lookup_kernel_symbol): Add support for
index 9fc207a..46df490 100644 (file)
@@ -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);
     }
 }
 
index d779723..3f9420d 100644 (file)
@@ -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 ()
 
index 928e637..8490270 100644 (file)
@@ -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;
            }
        }
index aba46c2..c30d05e 100644 (file)
--- 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 *