Skip to content

Commit

Permalink
HPCC-31984 Capture additional stats from CSmartRowBuffer temp files
Browse files Browse the repository at this point in the history
* Capture stats such as StCycleSpillElapsedCycles and StTimeSpillElapsed
from temp file
* Have CSmartRowBuffer use StSizeDiskWrite from tempFileIO for noteSize (should mean
actual disk size used for size tracking)

Signed-off-by: Shamser Ahmed <[email protected]>
  • Loading branch information
shamser committed Aug 13, 2024
1 parent 0e5fafa commit 2c3b65b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions thorlcr/activities/hashdistrib/thhashdistribslave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,8 @@ class CDistributorBase : implements IHashDistributor, implements IExceptionHandl

virtual void mergeStats(CRuntimeStatisticCollection &stats) const
{
if (piperd)
mergeRemappedStats(stats, piperd, diskToTempStatsMap);
sender.mergeStats(stats);
}
// IExceptionHandler impl.
Expand Down
25 changes: 24 additions & 1 deletion thorlcr/thorutil/thbuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ class CSmartRowBuffer: public CSimpleInterface, implements ISmartRowBuffer, impl
{
return this;
}
virtual unsigned __int64 getStatistic(StatisticKind kind) const override
{
if (tempFileIO)
return tempFileIO->getStatistic(kind);
else
return 0;
}
};


Expand Down Expand Up @@ -607,6 +614,10 @@ class CSmartRowInMemoryBuffer: public CSimpleInterface, implements ISmartRowBuff
{
return this;
}
virtual unsigned __int64 getStatistic(StatisticKind kind) const override
{
return 0;
}
};


Expand Down Expand Up @@ -733,6 +744,7 @@ class CCompressedSpillingRowStream: public CSimpleInterfaceOf<ISmartRowBuffer>,
RowEntry readFromStreamMarker = { nullptr, 0, 0 };

// misc
CRuntimeStatisticCollection inactiveStats;
bool grouped = false; // ctor input parameter
CriticalSection readerWriterCS;
#ifdef STRESSTEST_SPILLING_ROWSTREAM
Expand All @@ -755,6 +767,9 @@ class CCompressedSpillingRowStream: public CSimpleInterfaceOf<ISmartRowBuffer>,
}
void createNextOutputStream()
{
if (currentOutputIFileIO)
mergeRemappedStats(inactiveStats, currentOutputIFileIO, diskToTempStatsMap);

VStringBuffer tmpFilename("%s.%u", baseTmpFilename.get(), writeTempFileNum++);
trace("WRITE: writing to %s", tmpFilename.str());
Owned<IFile> iFile = createIFile(tmpFilename);
Expand Down Expand Up @@ -1005,7 +1020,8 @@ class CCompressedSpillingRowStream: public CSimpleInterfaceOf<ISmartRowBuffer>,

explicit CCompressedSpillingRowStream(CActivityBase *_activity, const char *_baseTmpFilename, bool _grouped, IThorRowInterfaces *rowIf, const LookAheadOptions &_options, ICompressHandler *_compressHandler)
: activity(*_activity), baseTmpFilename(_baseTmpFilename), grouped(_grouped), options(_options), compressHandler(_compressHandler),
meta(rowIf->queryRowMetaData()), serializer(rowIf->queryRowSerializer()), allocator(rowIf->queryRowAllocator()), deserializer(rowIf->queryRowDeserializer())
meta(rowIf->queryRowMetaData()), serializer(rowIf->queryRowSerializer()), allocator(rowIf->queryRowAllocator()), deserializer(rowIf->queryRowDeserializer()),
inactiveStats(spillStatistics)
{
size32_t minSize = meta->getMinRecordSize();

Expand Down Expand Up @@ -1053,6 +1069,13 @@ class CCompressedSpillingRowStream: public CSimpleInterfaceOf<ISmartRowBuffer>,
{
return this;
}
virtual unsigned __int64 getStatistic(StatisticKind kind) const
{
unsigned __int64 v = inactiveStats.queryStatistic(kind).get();
if (currentOutputIFileIO)
v += currentOutputIFileIO->getStatistic(kind);
return v;
}
// IRowStream
virtual const void *nextRow() override
{
Expand Down
1 change: 1 addition & 0 deletions thorlcr/thorutil/thbuf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct LookAheadOptions : CommonBufferRowRWStreamOptions
interface ISmartRowBuffer: extends IRowStream
{
virtual IRowWriter *queryWriter() = 0;
virtual unsigned __int64 getStatistic(StatisticKind kind) const = 0;
};

class CActivityBase;
Expand Down

0 comments on commit 2c3b65b

Please sign in to comment.