-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HPCC-32138 Generic remapping merge function to remap disk stats to spill stats #18819
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-32138 Jirabot Action Result: |
776416d
to
0878095
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - please see comments.
thorlcr/thorutil/thbuf.cpp
Outdated
if (likely(iFileIO)) | ||
v = iFileIO->getStatistic(useKind); | ||
v += inactiveStats.getStatisticValue(useKind); | ||
v = iFileIO->getStatistic(kind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is potential thread unsafe. iFileIO could be null at this point, i.e. closeWriter could get in between the test and this line
Also shouldn't this still be v += ? inactive + current IFileIO stats?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re. the thread safety an alternative is not to examine the potentially changing thread-unsafe iFileIO here at all,
instead merge the stats into a stats container (e.g. inactive) when they are written, i.e. at the end of writeRowsFromInput().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - this potentially thread unsafe implementation seems to have been reintroduced in latest version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - looks good. Please squash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - looks good.
@shamser - can you retarget this to 9.6 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved.
@ghalliday - please merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser I think this is double counting. Have we got tests to verify this isn't happening (e.g. set watchdog frequency to 1s to make it obvious)?
@@ -99,6 +99,11 @@ const StatisticsMapping hashDistribActivityStatistics({StNumLocalRows, StNumRemo | |||
const StatisticsMapping nsplitterActivityStatistics({}, spillStatistics, basicActivityStatistics); | |||
const StatisticsMapping spillingWriteAheadStatistics({}, spillStatistics); | |||
|
|||
const StatKindMap diskToTempStatsMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should ideally have a comment to indicate which is the source and which is the target
thorlcr/thorutil/thbuf.cpp
Outdated
@@ -2549,6 +2538,7 @@ class CSharedFullSpillingWriteAhead : public CInterfaceOf<ISharedRowStreamReader | |||
outputStream->flush(); | |||
totalInputRowsRead.fetch_add(newRowsWritten); | |||
tempFileOwner->noteSize(iFileIO->getStatistic(StSizeDiskWrite)); | |||
::mergeStats(inactiveStats, iFileIO); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is going to double count the stats. Each time it is called it will add the stats from the previous call as well as the rows just written.
good idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - 1 issue.
@ghalliday - could merge as is and revisit if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser
Squashing these commits made it very hard to understand what changes had been madE.
NOTE this comment from Jake before:
this is potential thread unsafe. iFileIO could be null at this point, i.e. closeWriter could get in between the test and this line
Also shouldn't this still be v += ? inactive + current IFileIO stats?
Member
@jakesmith jakesmith last week
re. the thread safety an alternative is not to examine the potentially changing thread-unsafe iFileIO here at all,
instead merge the stats into a stats container (e.g. inactive) when they are written, i.e. at the end of writeRowsFromInput().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shamser - please see comments re. getStatistic/iFileIO thread safety issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's an issue with when/where the remapping is done in the splitter/CSharedFullSpillingWriteAhead code.
Has this been tested?
I ran a quick test and not see the stats. I was expecting (Size*SpillFile stats were missing).
thorlcr/thorutil/thbuf.cpp
Outdated
@@ -2549,6 +2543,9 @@ class CSharedFullSpillingWriteAhead : public CInterfaceOf<ISharedRowStreamReader | |||
outputStream->flush(); | |||
totalInputRowsRead.fetch_add(newRowsWritten); | |||
tempFileOwner->noteSize(iFileIO->getStatistic(StSizeDiskWrite)); | |||
CRuntimeStatisticCollection currentFileStats(inactiveStats.queryMapping()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: I think "inactiveStats" could do with renaming now, as it's active, "stats" is probably clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it worth having some functions like the following in jstats::
template <class INTERFACE>
void updateStatsDelta(CRuntimeStatisticCollection & fullStats, CRuntimeStatisticCollection & deltaStats, INTERFACE * source)
{
CRuntimeStatisticCollection curStats(deltaStats.queryMapping());
mergeStats(curStats, source);
fullStats.updateDelta(deltaStats, curStats);
}
then this would be
updateStatsDelta(inactiveStats, previousFileStats, iFileIO);
thorlcr/thorutil/thbuf.cpp
Outdated
@@ -2549,6 +2543,9 @@ class CSharedFullSpillingWriteAhead : public CInterfaceOf<ISharedRowStreamReader | |||
outputStream->flush(); | |||
totalInputRowsRead.fetch_add(newRowsWritten); | |||
tempFileOwner->noteSize(iFileIO->getStatistic(StSizeDiskWrite)); | |||
CRuntimeStatisticCollection currentFileStats(inactiveStats.queryMapping()); | |||
::mergeStats(currentFileStats, iFileIO); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is right.
currenFileStats has a spillingWriteAheadStatistics mapping, those stats are not within iFileIO ..
I think you either need to store as a mapping based on diskLocalStatistic, and allow the caller to remap (that's what the splitter code is doing), or, remap here and have no remapping in the caller.
It is probably better to accrue the stats in this container unmapped, and only remap in gatherStatistics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with that - accumulate in the natural form, and map when it is added to an activity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakesmith a couple of comments. I agree with your comments.
thorlcr/thorutil/thbuf.cpp
Outdated
@@ -2549,6 +2543,9 @@ class CSharedFullSpillingWriteAhead : public CInterfaceOf<ISharedRowStreamReader | |||
outputStream->flush(); | |||
totalInputRowsRead.fetch_add(newRowsWritten); | |||
tempFileOwner->noteSize(iFileIO->getStatistic(StSizeDiskWrite)); | |||
CRuntimeStatisticCollection currentFileStats(inactiveStats.queryMapping()); | |||
::mergeStats(currentFileStats, iFileIO); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with that - accumulate in the natural form, and map when it is added to an activity.
thorlcr/thorutil/thbuf.cpp
Outdated
@@ -2549,6 +2543,9 @@ class CSharedFullSpillingWriteAhead : public CInterfaceOf<ISharedRowStreamReader | |||
outputStream->flush(); | |||
totalInputRowsRead.fetch_add(newRowsWritten); | |||
tempFileOwner->noteSize(iFileIO->getStatistic(StSizeDiskWrite)); | |||
CRuntimeStatisticCollection currentFileStats(inactiveStats.queryMapping()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it worth having some functions like the following in jstats::
template <class INTERFACE>
void updateStatsDelta(CRuntimeStatisticCollection & fullStats, CRuntimeStatisticCollection & deltaStats, INTERFACE * source)
{
CRuntimeStatisticCollection curStats(deltaStats.queryMapping());
mergeStats(curStats, source);
fullStats.updateDelta(deltaStats, curStats);
}
then this would be
updateStatsDelta(inactiveStats, previousFileStats, iFileIO);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakesmith I think this is good enough to merge. We should separately review all the mappings and make them consistent and clearly structured.
@@ -2562,7 +2555,7 @@ class CSharedFullSpillingWriteAhead : public CInterfaceOf<ISharedRowStreamReader | |||
explicit CSharedFullSpillingWriteAhead(CActivityBase *_activity, unsigned _numOutputs, IRowStream *_input, bool _inputGrouped, const SharedRowStreamReaderOptions &_options, IThorRowInterfaces *rowIf, const char *_baseTmpFilename, ICompressHandler *_compressHandler) | |||
: activity(*_activity), numOutputs(_numOutputs), input(_input), inputGrouped(_inputGrouped), options(_options), compressHandler(_compressHandler), baseTmpFilename(_baseTmpFilename), | |||
meta(rowIf->queryRowMetaData()), serializer(rowIf->queryRowSerializer()), allocator(rowIf->queryRowAllocator()), deserializer(rowIf->queryRowDeserializer()), | |||
inactiveStats(spillingWriteAheadStatistics) | |||
inactiveStats(spillingWriteAheadStatistics), previousFileStats(spillingWriteAheadStatistics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite the right mapping - it shouldn't include StSizePeakTempDisk, but it is good enough for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think changed in the other pending PR - which will therefore need rebasing once this is merged.
…ill stats Signed-off-by: Shamser Ahmed <[email protected]> Signed-off-by: Jake Smith <[email protected]>
b32d940
into
hpcc-systems:candidate-9.6.x
…ent a generic mergeStats function that will remap to the stat names before setting them
Type of change:
Checklist:
Smoketest:
Testing: