Use a struct for the set of spark counters
authorDuncan Coutts <duncan@well-typed.com>
Wed, 1 Jun 2011 18:38:15 +0000 (19:38 +0100)
committerDuncan Coutts <duncan@well-typed.com>
Mon, 18 Jul 2011 15:31:14 +0000 (16:31 +0100)
rts/Capability.c
rts/Capability.h
rts/Sparks.c
rts/Sparks.h
rts/Stats.c

index a9bb743..e12bf99 100644 (file)
@@ -94,11 +94,11 @@ findSpark (Capability *cap)
       // slower (prsa) and doesn't affect the others.
       spark = tryStealSpark(cap->sparks);
       while (spark != NULL && fizzledSpark(spark)) {
-          cap->sparks_fizzled++;
+          cap->spark_stats.fizzled++;
           spark = tryStealSpark(cap->sparks);
       }
       if (spark != NULL) {
-          cap->sparks_converted++;
+          cap->spark_stats.converted++;
 
           // Post event for running a spark from capability's own pool.
           traceEventRunSpark(cap, cap->r.rCurrentTSO);
@@ -127,7 +127,7 @@ findSpark (Capability *cap)
 
           spark = tryStealSpark(robbed->sparks);
           while (spark != NULL && fizzledSpark(spark)) {
-              cap->sparks_fizzled++;
+              cap->spark_stats.fizzled++;
               spark = tryStealSpark(robbed->sparks);
           }
           if (spark == NULL && !emptySparkPoolCap(robbed)) {
@@ -137,7 +137,7 @@ findSpark (Capability *cap)
           }
 
           if (spark != NULL) {
-              cap->sparks_converted++;
+              cap->spark_stats.converted++;
 
               traceEventStealSpark(cap, cap->r.rCurrentTSO, robbed->no);
               
@@ -232,11 +232,11 @@ initCapability( Capability *cap, nat i )
     cap->returning_tasks_hd = NULL;
     cap->returning_tasks_tl = NULL;
     cap->inbox              = (Message*)END_TSO_QUEUE;
-    cap->sparks_created     = 0;
-    cap->sparks_dud         = 0;
-    cap->sparks_converted   = 0;
-    cap->sparks_gcd         = 0;
-    cap->sparks_fizzled     = 0;
+    cap->spark_stats.created    = 0;
+    cap->spark_stats.dud        = 0;
+    cap->spark_stats.converted  = 0;
+    cap->spark_stats.gcd        = 0;
+    cap->spark_stats.fizzled    = 0;
 #endif
 
     cap->f.stgEagerBlackholeInfo = (W_)&__stg_EAGER_BLACKHOLE_info;
index d380af9..2037989 100644 (file)
@@ -98,11 +98,7 @@ struct Capability_ {
     SparkPool *sparks;
 
     // Stats on spark creation/conversion
-    nat sparks_created;
-    nat sparks_dud;
-    nat sparks_converted;
-    nat sparks_gcd;
-    nat sparks_fizzled;
+    SparkCounters spark_stats;
 #endif
 
     // Per-capability STM-related data
index 5c78055..d358ae6 100644 (file)
@@ -65,9 +65,9 @@ newSpark (StgRegTable *reg, StgClosure *p)
 
     if (!fizzledSpark(p)) {
         pushWSDeque(pool,p);
-        cap->sparks_created++;
+        cap->spark_stats.created++;
     } else {
-        cap->sparks_dud++;
+        cap->spark_stats.dud++;
     }
 
     return 1;
@@ -173,7 +173,7 @@ pruneSparkQueue (Capability *cap)
           // evaluated, but it doesn't hurt to have this check for
           // robustness.
           pruned_sparks++;
-          cap->sparks_fizzled++;
+          cap->spark_stats.fizzled++;
       } else {
           info = spark->header.info;
           if (IS_FORWARDING_PTR(info)) {
@@ -185,7 +185,7 @@ pruneSparkQueue (Capability *cap)
                   n++;
               } else {
                   pruned_sparks++; // discard spark
-                  cap->sparks_fizzled++;
+                  cap->spark_stats.fizzled++;
               }
           } else if (HEAP_ALLOCED(spark)) {
               if ((Bdescr((P_)spark)->flags & BF_EVACUATED)) {
@@ -195,11 +195,11 @@ pruneSparkQueue (Capability *cap)
                       n++;
                   } else {
                       pruned_sparks++; // discard spark
-                      cap->sparks_fizzled++;
+                      cap->spark_stats.fizzled++;
                   }
               } else {
                   pruned_sparks++; // discard spark
-                  cap->sparks_gcd++;
+                  cap->spark_stats.gcd++;
               }
           } else {
               if (INFO_PTR_TO_STRUCT(info)->type == THUNK_STATIC) {
@@ -209,11 +209,11 @@ pruneSparkQueue (Capability *cap)
                       n++;
                   } else {
                       pruned_sparks++; // discard spark
-                      cap->sparks_gcd++;
+                      cap->spark_stats.gcd++;
                   }
               } else {
                   pruned_sparks++; // discard spark
-                  cap->sparks_fizzled++;
+                  cap->spark_stats.fizzled++;
               }
           }
       }
index e3ddc0c..c987a94 100644 (file)
 
 /* typedef for SparkPool in RtsTypes.h */
 
+/* Stats on spark creation/conversion */
+typedef struct {
+    StgWord created;
+    StgWord dud;
+    StgWord converted;
+    StgWord gcd;
+    StgWord fizzled;
+} SparkCounters;
+
 #if defined(THREADED_RTS)
 
 typedef WSDeque SparkPool;
index 9fc702a..04b091c 100644 (file)
@@ -629,21 +629,19 @@ stat_exit(int alloc)
 
             {
                 nat i;
-                lnat sparks_created   = 0;
-                lnat sparks_dud       = 0;
-                lnat sparks_converted = 0;
-                lnat sparks_gcd       = 0;
-                lnat sparks_fizzled   = 0;
+                SparkCounters sparks = { 0, 0, 0, 0, 0};
                 for (i = 0; i < n_capabilities; i++) {
-                    sparks_created   += capabilities[i].sparks_created;
-                    sparks_dud       += capabilities[i].sparks_dud;
-                    sparks_converted += capabilities[i].sparks_converted;
-                    sparks_gcd       += capabilities[i].sparks_gcd;
-                    sparks_fizzled   += capabilities[i].sparks_fizzled;
+                    sparks.created   += capabilities[i].spark_stats.created;
+                    sparks.dud       += capabilities[i].spark_stats.dud;
+                    sparks.converted += capabilities[i].spark_stats.converted;
+                    sparks.gcd       += capabilities[i].spark_stats.gcd;
+                    sparks.fizzled   += capabilities[i].spark_stats.fizzled;
                 }
 
                 statsPrintf("  SPARKS: %ld (%ld converted, %ld dud, %ld GC'd, %ld fizzled)\n\n",
-                            sparks_created + sparks_dud, sparks_converted, sparks_dud, sparks_gcd, sparks_fizzled);
+                            sparks.created + sparks.dud,
+                            sparks.converted, sparks.dud,
+                            sparks.gcd, sparks.fizzled);
             }
 #endif