-
Notifications
You must be signed in to change notification settings - Fork 306
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-32108 Gather and report regex cache statistics #19193
HPCC-32108 Gather and report regex cache statistics #19193
Conversation
Jira Issue: https://hpccsystems.atlassian.net//browse/HPCC-32108 Jirabot Action Result: |
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.
There are just a few minor suggestions.
common/thorhelper/thorstats.cpp
Outdated
@@ -20,34 +20,63 @@ | |||
#include "thorstats.hpp" | |||
#include "jdebug.hpp" | |||
|
|||
// Available sets of statistics for a nested section | |||
const StatisticsMapping defaultNestedSectionStatistics({StCycleLocalExecuteCycles, StTimeLocalExecute, StNumStarts, StNumStops}); | |||
const StatisticsMapping genericCacheNestedSectionStatistics({StCycleLocalExecuteCycles, StTimeLocalExecute, StNumStarts, StNumStops, StNumCacheAdds, StNumCacheHits, StNumPeakCacheObjects}); |
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.
genericCacheNestedSectionStatistics should build on defaultNestedSectionStatistics so that if defaults are ever changed, the changes are reflected in genericCacheNestedSectionStatistics:
const StatisticsMapping genericCacheNestedSectionStatistics(defaultNestedSectionStatistics, {StNumCacheAdds, StNumCacheHits, StNumPeakCacheObjects})
const StatisticsMapping genericCacheNestedSectionStatistics({StCycleLocalExecuteCycles, StTimeLocalExecute, StNumStarts, StNumStops, StNumCacheAdds, StNumCacheHits, StNumPeakCacheObjects}); | |
const StatisticsMapping genericCacheNestedSectionStatistics({StCycleLocalExecuteCycles, StTimeLocalExecute, StNumStarts, StNumStops, StNumCacheAdds, StNumCacheHits, StNumPeakCacheObjects}); |
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.
Fixed. Note that defaultNestedSectionStatistics is actually the last arg to the next constructor rather than the first.
common/thorhelper/thorstats.cpp
Outdated
} | ||
|
||
unsigned __int64 ThorSectionTimer::getStartCycles() | ||
{ | ||
starts.addAtomic(1); | ||
nested.queryStatistic(StNumStarts).addAtomic(1); |
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:
nested.addStatisticAtomic(StNumStarts, 1)
common/thorhelper/thorstats.cpp
Outdated
elapsed.addAtomic(delay); | ||
stops.addAtomic(1); | ||
nested.queryStatistic(StCycleLocalExecuteCycles).addAtomic(delay); | ||
nested.queryStatistic(StNumStops).addAtomic(1); |
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: nested.addStatisticAtomic should be used.
common/thorhelper/thorstats.cpp
Outdated
|
||
void ThorSectionTimer::mergeStatistic(__int64 kind, unsigned __int64 value) | ||
{ | ||
nested.queryStatistic(static_cast<StatisticKind>(kind)).merge(value, queryMergeMode(static_cast<StatisticKind>(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.
nested.mergeStatistic(static_cast(kind), value) should be used. MergeMode will be handled by CRuntimeStatistic
common/thorhelper/thorstats.cpp
Outdated
|
||
void ThorSectionTimer::setStatistic(__int64 kind, unsigned __int64 value) | ||
{ | ||
nested.queryStatistic(static_cast<StatisticKind>(kind)).set(value); |
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: preferable to use nested.setStatistic()
common/thorhelper/thorstats.cpp
Outdated
|
||
void ThorSectionTimer::addStatistic(__int64 kind, unsigned __int64 value) | ||
{ | ||
nested.queryStatistic(static_cast<StatisticKind>(kind)).addAtomic(value); |
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: preferable to use nested.addStatisticAtomic()
ecl/hqlcpp/hqlhtcpp.cpp
Outdated
@@ -18828,7 +18828,16 @@ void HqlCppTranslator::buildTimerBase(BuildCtx & ctx, CHqlBoundExpr & boundTimer | |||
HqlExprArray registerArgs; | |||
registerArgs.append(*getSizetConstant(activityId)); | |||
registerArgs.append(*createConstant(name)); | |||
OwnedHqlExpr call = bindFunctionCall(registerTimerId, registerArgs); | |||
OwnedHqlExpr call; | |||
if (statsOption == 0) |
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.
clearer to
if (statsOption==ThorStatDefault)
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, but making ThorStatDefault visible would require including a header and I am loathe to do so at this point. I did add a comment here, nothing what the zero actually means. I can, of course, include the header and use the enum value name instead if you really think it is worth it; let me know.
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.
@dcamper looks like a good change. A few minor comments (including those from Shamser), but looks like it is close to ready to merge.
common/thorhelper/thorstats.hpp
Outdated
StringAttr name; | ||
CRuntimeStatisticCollection & nested; |
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.
picky: From this classes' point of view it is not nested, so "stats" would be a simpler/clearer name.
@@ -361,6 +361,20 @@ ISectionTimer * CActivityCodeContext::registerTimer(unsigned activityId, const c | |||
return timer; | |||
} | |||
|
|||
ISectionTimer * CActivityCodeContext::registerStatsTimer(unsigned activityId, const char * name, unsigned int statsOption) |
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.
cleanup: I would reimplement the function above by calling this with the default argument. Reduces code, and ensure the new function is tested in many existing situations.
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.
Thanks for catching this. It was on my TODO and I missed it.
@@ -6127,7 +6129,9 @@ void HqlCppTranslator::doBuildCall(BuildCtx & ctx, const CHqlBoundTarget * tgt, | |||
const char * name = str(external->queryId()); | |||
if (getStringValue(nameTemp, queryAttributeChild(external, timerAtom, 0)).length()) | |||
name = nameTemp; | |||
buildHelperTimer(ctx, boundTimer, name); | |||
// Grab optional ThorStatOption enum (as an int) | |||
int statOption = getIntValue(queryAttributeChild(external, timerAtom, 1), 0); |
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.
type should be consistent with the call above (int v __int64)
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.
Fixed.
@@ -2147,6 +2147,18 @@ class CRoxieContextBase : implements IRoxieAgentContext, implements ICodeContext | |||
} | |||
return timer; | |||
} | |||
virtual ISectionTimer * registerStatsTimer(unsigned activityId, const char * name, unsigned int statsOption) |
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.
again (and in all other non-trivial occasions) worth re-implementing the old function by calling the new.
@ghalliday Changes made, please re-review. Thanks! |
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.
Looks good.
1685b28
to
4ec6e9b
Compare
Aside: Force-pushed an update to resolve a conflict when I rebased with the latest master branch updates. |
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.
@dcamper looks good. A few final comments (which can be ignored). Please squash.
roxie/ccd/ccdserver.cpp
Outdated
@@ -1309,6 +1316,18 @@ class CRoxieServerActivity : implements CInterfaceOf<IRoxieServerActivity>, impl | |||
} | |||
return timer; | |||
} | |||
virtual ISectionTimer *registerStatsTimer(unsigned activityId, const char * name, unsigned int statsOption) | |||
{ | |||
CriticalBlock b(statscrit); // reuse statscrit to protect functionTimers - it will not be held concurrently |
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.
trivial: another case where the old could call the new
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.
Argh. I missed that one. Thanks for catching it.
4ec6e9b
to
fde7031
Compare
@ghalliday Squashed. Thanks! |
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.
@dcamper see comment
common/thorhelper/thorstats.cpp
Outdated
@@ -20,34 +20,63 @@ | |||
#include "thorstats.hpp" | |||
#include "jdebug.hpp" | |||
|
|||
// Available sets of statistics for a nested section | |||
const StatisticsMapping defaultNestedSectionStatistics({StCycleLocalExecuteCycles, StTimeLocalExecute, StNumStarts, StNumStops}); | |||
const StatisticsMapping genericCacheNestedSectionStatistics({StNumCacheHits, StNumPeakCacheObjects}, defaultNestedSectionStatistics); |
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.
Missing StNumCacheAdds...
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.
Fixed.
fde7031
to
0f6e244
Compare
This PR also opens up ISectionTimer so that other code can define and set nested statistics. In addition, a general type of "peak number/count" statistic has been defined.
Type of change:
Checklist:
Smoketest:
Testing:
Manual test via workunit submission, staring at ECL Watch, and reviewing wutool output.