Eventlog support for new event type: create spark.
authordonnie@darthik.com <unknown>
Fri, 3 Apr 2009 03:30:25 +0000 (03:30 +0000)
committerdonnie@darthik.com <unknown>
Fri, 3 Apr 2009 03:30:25 +0000 (03:30 +0000)
includes/EventLogFormat.h
rts/Capability.c
rts/Schedule.c
rts/Sparks.c
rts/eventlog/EventLog.c

index 5fbfe9b..a8a5a83 100644 (file)
 #define EVENT_GC_END         10 /* (cap) */
 #define EVENT_REQUEST_SEQ_GC 11 /* (cap) */
 #define EVENT_REQUEST_PAR_GC 12 /* (cap) */
+#define EVENT_CREATE_SPARK   13 /* (cap, thread)              */
 
-#define NUM_EVENT_TAGS       13 
+#define NUM_EVENT_TAGS       14 
 
 /*
  * Status values for EVENT_STOP_THREAD
index 05e9126..fcfca3c 100644 (file)
@@ -79,6 +79,10 @@ findSpark (Capability *cap)
   spark = tryStealSpark(cap);
   if (spark != NULL) {
       cap->sparks_converted++;
+
+      // Post event for running a spark from capability's own pool.
+      postEvent(cap, EVENT_RUN_SPARK, cap->r.rCurrentTSO->id, 0);
+
       return spark;
   }
 
@@ -113,6 +117,11 @@ findSpark (Capability *cap)
                 "cap %d: Stole a spark from capability %d",
                          cap->no, robbed->no);
               cap->sparks_converted++;
+
+              postEvent(cap, EVENT_STEAL_SPARK, 
+                        cap->r.rCurrentTSO->id, robbed->no);
+                        
+              
               return spark;
           }
           // otherwise: no success, try next one
index 141c973..e82115b 100644 (file)
@@ -858,7 +858,7 @@ schedulePushWork(Capability *cap USED_IF_THREADS,
                    debugTrace(DEBUG_sched, "pushing thread %lu to capability %d", (unsigned long)t->id, free_caps[i]->no);
                    appendToRunQueue(free_caps[i],t);
 
-                    postEvent (cap, EVENT_MIGRATE_THREAD, t->id, free_caps[i]->no);
+        postEvent (cap, EVENT_MIGRATE_THREAD, t->id, free_caps[i]->no);
 
                    if (t->bound) { t->bound->cap = free_caps[i]; }
                    t->cap = free_caps[i];
@@ -881,6 +881,9 @@ schedulePushWork(Capability *cap USED_IF_THREADS,
                    spark = tryStealSpark(cap->sparks);
                    if (spark != NULL) {
                        debugTrace(DEBUG_sched, "pushing spark %p to capability %d", spark, free_caps[i]->no);
+
+      postEvent(free_caps[i], EVENT_STEAL_SPARK, t->id, cap->no);
+
                        newSpark(&(free_caps[i]->r), spark);
                    }
                }
index 3fccdb6..aed75e5 100644 (file)
@@ -57,6 +57,7 @@ createSparkThread (Capability *cap)
 
     tso = createIOThread (cap, RtsFlags.GcFlags.initialStkSize, 
                           &base_GHCziConc_runSparks_closure);
+
     appendToRunQueue(cap,tso);
 }
 
@@ -83,6 +84,8 @@ newSpark (StgRegTable *reg, StgClosure *p)
 
     cap->sparks_created++;
 
+    postEvent(cap, EVENT_CREATE_SPARK, reg->rCurrentTSO->id, 0);
+
     return 1;
 }
 
index 820e95c..3411235 100644 (file)
@@ -48,7 +48,8 @@ char *EventDesc[] = {
   "Request sequential GC",
   "Request parallel GC",
   "Starting GC",
-  "Finished GC"
+  "Finished GC",
+  "Create spark"
 };
 
 // Event type. 
@@ -176,6 +177,7 @@ initEventLogging(void)
         case EVENT_CREATE_THREAD:   // (cap, thread)
         case EVENT_RUN_THREAD:      // (cap, thread)
         case EVENT_THREAD_RUNNABLE: // (cap, thread)
+        case EVENT_CREATE_SPARK:    // (cap, thread)
         case EVENT_RUN_SPARK:       // (cap, thread)
             eventTypes[t].size = sizeof(CapabilityNum) + sizeof(ThreadID);
             break;
@@ -298,6 +300,7 @@ postEvent_(Capability *cap, EventTypeNum tag, StgThreadID thread, nat other_cap)
     case EVENT_CREATE_THREAD:   // (cap, thread)
     case EVENT_RUN_THREAD:      // (cap, thread)
     case EVENT_THREAD_RUNNABLE: // (cap, thread)
+    case EVENT_CREATE_SPARK:    // (cap, thread)
     case EVENT_RUN_SPARK:       // (cap, thread)
     {
         postWord64(eb,thread);