gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r11495 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r11495 - gnunet/src/util
Date: Tue, 25 May 2010 17:46:31 +0200

Author: grothoff
Date: 2010-05-25 17:46:31 +0200 (Tue, 25 May 2010)
New Revision: 11495

Modified:
   gnunet/src/util/scheduler.c
Log:
time tracking

Modified: gnunet/src/util/scheduler.c
===================================================================
--- gnunet/src/util/scheduler.c 2010-05-25 09:12:13 UTC (rev 11494)
+++ gnunet/src/util/scheduler.c 2010-05-25 15:46:31 UTC (rev 11495)
@@ -31,13 +31,32 @@
 #include "gnunet_time_lib.h"
 #ifdef LINUX
 #include "execinfo.h"
+/**
+ * Obtain trace information for all scheduler calls that schedule tasks.
+ */
 #define EXECINFO GNUNET_NO
+
+/**
+ * Depth of the traces collected via EXECINFO.
+ */
 #define MAX_TRACE_DEPTH 50
 #endif
 
 #define DEBUG_TASKS GNUNET_NO
 
 /**
+ * Should we figure out which tasks are delayed for a while
+ * before they are run? (Consider using in combination with EXECINFO).
+ */
+#define PROFILE_DELAYS GNUNET_NO
+
+/**
+ * Task that were in the queue for longer than this are reported if
+ * PROFILE_DELAYS is active.
+ */
+#define DELAY_THRESHOLD GNUNET_TIME_UNIT_SECONDS
+
+/**
  * Linked list of pending tasks.
  */
 struct Task
@@ -88,7 +107,14 @@
    */
   struct GNUNET_TIME_Absolute timeout;
 
+#if PROFILE_DELAYS
   /**
+   * When was the task scheduled?
+   */
+  struct GNUNET_TIME_Absolute start_time;
+#endif
+
+  /**
    * Why is the task ready?  Set after task is added to ready queue.
    * Initially set to zero.  All reasons that have already been
    * satisfied (i.e.  read or write ready) will be set over time.
@@ -507,6 +533,25 @@
          (void) GNUNET_OS_set_process_priority (0, pos->priority);
        }
       sched->active_task = pos;
+#if PROFILE_DELAYS
+      if (GNUNET_TIME_absolute_get_duration (pos->start_time).value >
+         DELAY_THRESHOLD.value)
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     "Task %u took %llums to be scheduled\n",
+                     pos->id,
+                     (unsigned long long) GNUNET_TIME_absolute_get_duration 
(pos->start_time).value);
+#if EXECINFO
+         int i;
+         for (i=0;i<pos->num_backtrace_strings;i++)
+           GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                       "Task %u trace %d: %s\n",
+                       pos->id,
+                       i,
+                       pos->backtrace_strings[i]);
+#endif
+       }
+#endif
       tc.sched = sched;
       tc.reason = pos->reason;
       tc.read_ready = pos->read_set;
@@ -792,6 +837,9 @@
   t->callback = task;
   t->callback_cls = task_cls;
   t->id = ++sched->last_id;
+#if PROFILE_DELAYS
+  t->start_time = GNUNET_TIME_absolute_get ();
+#endif
   t->reason = reason;
   t->priority = sched->current_priority;
 #if DEBUG_TASKS
@@ -1129,6 +1177,9 @@
       GNUNET_NETWORK_fdset_copy (t->write_set, ws);
     }
   t->id = ++sched->last_id;
+#if PROFILE_DELAYS
+  t->start_time = GNUNET_TIME_absolute_get ();
+#endif
   t->prereq_id = prerequisite_task;
   t->timeout = GNUNET_TIME_relative_to_absolute (delay);
   t->priority =




reply via email to

[Prev in Thread] Current Thread [Next in Thread]