diff --git a/common/thorhelper/thorcommon.hpp b/common/thorhelper/thorcommon.hpp index 157ed31cace..2393b041301 100644 --- a/common/thorhelper/thorcommon.hpp +++ b/common/thorhelper/thorcommon.hpp @@ -315,7 +315,7 @@ class SimpleActivityTimer cycle_t startCycles; cycle_t &accumulator; protected: - mutable bool enabled; + const bool enabled; public: inline SimpleActivityTimer(cycle_t &_accumulator, const bool _enabled) : accumulator(_accumulator), enabled(_enabled) @@ -327,17 +327,12 @@ class SimpleActivityTimer } inline ~SimpleActivityTimer() - { - leave(); - } - inline void leave() { if (likely(enabled)) { cycle_t nowCycles = get_cycles_now(); cycle_t elapsedCycles = nowCycles - startCycles; accumulator += elapsedCycles; - enabled = false; } } }; diff --git a/thorlcr/activities/funnel/thfunnelslave.cpp b/thorlcr/activities/funnel/thfunnelslave.cpp index 78dc7cf70d6..c2b7f4978b1 100644 --- a/thorlcr/activities/funnel/thfunnelslave.cpp +++ b/thorlcr/activities/funnel/thfunnelslave.cpp @@ -89,13 +89,15 @@ class CParallelFunnel : implements IRowStream, public CSimpleInterface while (!stopping) { numRows = 0; - for (;numRows < chunkSize; numRows++) { LookAheadTimer timer(funnel.activity.getActivityTimerAccumulator(), funnel.activity.queryTimeActivities()); - const void * row = inputStream->ungroupedNextRow(); - if (!row) - break; - rows[numRows] = row; + for (;numRows < chunkSize; numRows++) + { + const void * row = inputStream->ungroupedNextRow(); + if (!row) + break; + rows[numRows] = row; + } } if (numRows == 0) break; @@ -201,7 +203,6 @@ class CParallelFunnel : implements IRowStream, public CSimpleInterface if (waitForSpace) { CriticalBlock b(writerCrit); - BlockedActivityTimer timer(activity.getActivityTimerAccumulator(), activity.queryTimeActivities()); fullSem.wait(); // block pushers on crit } } @@ -297,9 +298,7 @@ class CParallelFunnel : implements IRowStream, public CSimpleInterface { if (exception) throw exception.getClear(); - BlockedActivityTimer timer(activity.getActivityTimerAccumulator(), activity.queryTimeActivities()); OwnedConstThorRow row = rows.dequeue(); - timer.leave(); if (!row) { rows.stop(); return NULL; @@ -384,7 +383,8 @@ class FunnelSlaveActivity : public CSlaveActivity { try { - LookAheadTimer timer(slaveTimerStats, timeActivities); + // n.b. i>0 is started asynchronously, so track look ahead time + LookAheadTimer timer(slaveTimerStats, (i==0) ? false : timeActivities); startInput(i); } catch (CATCHALL)