Selaa lähdekoodia

HPCC-12282 Move roxie query stats to use new mechanism

Minor changes following code review

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 vuotta sitten
vanhempi
commit
6c43db3345

+ 24 - 10
common/thorhelper/thorcommon.hpp

@@ -140,13 +140,27 @@ public:
         firstExitCycles = 0;
     }
 public:
-    unsigned __int64 startCycles; // Wall clock time of first entry to this activity
-    unsigned __int64 totalCycles; // Time spent in this activity
-    unsigned __int64 endCycles;   // Wall clock time of last entry to this activity
-    unsigned __int64 firstRow;    // Timestamp of first row
-    unsigned __int64 firstExitCycles;    // Wall clock time of first exit from this activity
+    cycle_t startCycles; // Wall clock time of first entry to this activity
+    cycle_t totalCycles; // Time spent in this activity
+    cycle_t endCycles;   // Wall clock time of last entry to this activity
+    unsigned __int64 firstRow; // Timestamp of first row (nanoseconds since epoch)
+    cycle_t firstExitCycles;    // Wall clock time of first exit from this activity
+
+    // Return the total amount of time (in nanoseconds) spent in this activity (first entry to last exit)
     inline unsigned __int64 elapsed() const { return cycle_to_nanosec(endCycles-startCycles); }
+    // Return the total amount of time (in nanoseconds) spent in the first call of this activity (first entry to first exit)
     inline unsigned __int64 latency() const { return cycle_to_nanosec(firstExitCycles-startCycles); }
+
+    void addStatistics(IStatisticGatherer & builder) const
+    {
+        if (totalCycles)
+        {
+            builder.addStatistic(StWhenFirstRow, firstRow);
+            builder.addStatistic(StTimeElapsed, elapsed());
+            builder.addStatistic(StTimeTotalExecute, cycle_to_nanosec(totalCycles));
+            builder.addStatistic(StTimeFirstExecute, latency());
+        }
+    }
 };
 
 #ifdef TIME_ACTIVITIES
@@ -183,7 +197,7 @@ public:
         {
             cycle_t nowCycles = get_cycles_now();
             accumulator.endCycles = nowCycles;
-            unsigned __int64 elapsedCycles = nowCycles - startCycles;
+            cycle_t elapsedCycles = nowCycles - startCycles;
             accumulator.totalCycles += elapsedCycles;
             if (isFirstRow)
                 accumulator.firstExitCycles = nowCycles;
@@ -193,12 +207,12 @@ public:
 
 class SimpleActivityTimer
 {
-    unsigned __int64 startCycles;
-    unsigned __int64 &accumulator;
+    cycle_t startCycles;
+    cycle_t &accumulator;
 protected:
     const bool enabled;
 public:
-    inline SimpleActivityTimer(unsigned __int64 &_accumulator, const bool _enabled)
+    inline SimpleActivityTimer(cycle_t &_accumulator, const bool _enabled)
     : accumulator(_accumulator), enabled(_enabled)
     {
         if (enabled)
@@ -212,7 +226,7 @@ public:
         if (enabled)
         {
             cycle_t nowCycles = get_cycles_now();
-            unsigned __int64 elapsedCycles = nowCycles - startCycles;
+            cycle_t elapsedCycles = nowCycles - startCycles;
             accumulator += elapsedCycles;
         }
     }

+ 3 - 13
roxie/ccd/ccdcontext.cpp

@@ -2704,20 +2704,10 @@ public:
             IStatisticGatherer & builder = graphStats->queryStatsBuilder();
             StatsSubgraphScope graphScope(builder, subgraphId);
             StatsActivityScope scope(builder, activityId);
-            if (_totalCycles.totalCycles)
-            {
-                builder.addStatistic(StWhenFirstRow, (_totalCycles.firstRow));
-                builder.addStatistic(StTimeElapsed, (_totalCycles.elapsed()));
-                builder.addStatistic(StTimeTotalExecute, cycle_to_nanosec(_totalCycles.totalCycles));
+            _totalCycles.addStatistics(builder);
+            if (_localCycles)
                 builder.addStatistic(StTimeLocalExecute, cycle_to_nanosec(_localCycles));
-            }
-            ForEachItemIn(i, fromStats)
-            {
-                StatisticKind kind = fromStats.getKind(i);
-                unsigned __int64 value = fromStats.getStatisticValue(kind);
-                if (value)
-                    builder.addStatistic(kind, value);
-            }
+            fromStats.recordStatistics(builder);
         }
         logctx.mergeStats(fromStats);
     }

+ 3 - 3
roxie/ccd/ccdserver.cpp

@@ -1736,7 +1736,7 @@ class CRoxieServerReadAheadInput : public CInterface, implements IRoxieInput, im
     bool disabled;
     RecordPullerThread puller;
     unsigned preload;
-    unsigned __int64 totalCycles;
+    cycle_t totalCycles;
     IRoxieSlaveContext *ctx;
     bool timeActivities;
 
@@ -3378,7 +3378,7 @@ public:
     ruid_t ruid;
     mutable CriticalSection buffersCrit;
     unsigned processed;
-    unsigned __int64 totalCycles;
+    cycle_t totalCycles;
     bool timeActivities;
 
 //private:   //vc6 doesn't like this being private yet accessed by nested class...
@@ -8326,7 +8326,7 @@ public:
         unsigned idx;
         unsigned oid;
         unsigned processed;
-        unsigned __int64 totalCycles;  // We track this per output so that the pullers get a meaningful value to use when calculating their localtime
+        cycle_t totalCycles;  // We track this per output so that the pullers get a meaningful value to use when calculating their localtime
 
     public:
         IMPLEMENT_IINTERFACE;

+ 1 - 0
system/jlib/jstats.cpp

@@ -499,6 +499,7 @@ static const StatisticMeta statsMetaData[StMax] = {
     { NUMSTAT(DiskAccepted) },
     { NUMSTAT(DiskRejected) },
     { TIMESTAT(Soapcall) },
+    { TIMESTAT(FirstExecute) },
 };
 
 

+ 2 - 1
system/jlib/jstats.h

@@ -98,7 +98,7 @@ enum StatisticMeasure
     St ## NodeMax ## y = (St ## x ## y | StNodeMax),
 
 //The values in this enumeration are stored persistently.  The associated values must not be changed.
-//If you add an entry here you must also update queryMeasure(), queryStatisticName() and queryTreeTag()
+//If you add an entry here you must also update statsMetaData
 //NOTE: All statistic names should be unique with the type prefix removed. Since the prefix is replaced with Skew/Min/etc.
 enum StatisticKind
 {
@@ -160,6 +160,7 @@ enum StatisticKind
     StNumDiskRejected,
 
     StTimeSoapcall,                     // Time spent waiting for soapcalls
+    StTimeFirstExecute,                 // Time waiting for first record from this activity
 
     StMax,