Skip to content

Commit

Permalink
HPCC-29790 Rationalise the way stages are represented in scopes
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Jan 19, 2024
1 parent 3a88a89 commit 5fafb3f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions system/jlib/jstatcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#define FileScopePrefix "p"
#define ChannelScopePrefix "x"
#define DFUWorkunitScopePrefix "D"
#define SectionScopePrefix "n"
#define OperationScopePrefix ">"

#define MATCHES_CONST_PREFIX(search, prefix) (strncmp(search, prefix, strlen(prefix)) == 0)

Expand Down
40 changes: 39 additions & 1 deletion system/jlib/jstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void setStatisticsComponentName(StatisticCreatorType processType, const char * p
// Textual forms of the different enumerations, first items are for none and all.
static constexpr const char * const measureNames[] = { "", "all", "ns", "ts", "cnt", "sz", "cpu", "skw", "node", "ppm", "ip", "cy", "en", "txt", "bool", "id", "fname", "cost", NULL };
static constexpr const char * const creatorTypeNames[]= { "", "all", "unknown", "hthor", "roxie", "roxie:s", "thor", "thor:m", "thor:s", "eclcc", "esp", "summary", NULL };
static constexpr const char * const scopeTypeNames[] = { "", "all", "global", "graph", "subgraph", "activity", "allocator", "section", "compile", "dfu", "edge", "function", "workflow", "child", "file", "channel", "unknown", nullptr };
static constexpr const char * const scopeTypeNames[] = { "", "all", "global", "graph", "subgraph", "activity", "allocator", "section", "stage", "dfu", "edge", "function", "workflow", "child", "file", "channel", "unknown", nullptr };

static unsigned matchString(const char * const * names, const char * search, unsigned dft)
{
Expand Down Expand Up @@ -1432,6 +1432,10 @@ StringBuffer & StatsScopeId::getScopeText(StringBuffer & out) const
return out.append(ChannelScopePrefix).append(id);
case SSTdfuworkunit:
return out.append(DFUWorkunitScopePrefix).append(name);
case SSTsection:
return out.append(SectionScopePrefix).append(name);
case SSToperation:
return out.append(OperationScopePrefix).append(name);
case SSTunknown:
return out.append(name);
case SSTglobal:
Expand Down Expand Up @@ -1674,6 +1678,11 @@ bool StatsScopeId::setScopeText(const char * text, const char * * _next)
setChildGraphId(strtoul(text+ strlen(ChildGraphScopePrefix), next, 10));
return true;
}
if (MATCHES_CONST_PREFIX(text, "compile"))
{
setOperationId("compile");
return true;
}
break;
case ChannelScopePrefix[0]:
if (MATCHES_CONST_PREFIX(text, ChannelScopePrefix) && isdigit(text[strlen(ChannelScopePrefix)]))
Expand All @@ -1691,6 +1700,24 @@ bool StatsScopeId::setScopeText(const char * text, const char * * _next)
return true;
}
break;
case SectionScopePrefix[0]:
if (MATCHES_CONST_PREFIX(text, SectionScopePrefix))
{
setSectionId(text+strlen(SectionScopePrefix));
if (_next)
*_next = text + strlen(text);
return true;
}
break;
case OperationScopePrefix[0]:
if (MATCHES_CONST_PREFIX(text, OperationScopePrefix))
{
setOperationId(text+strlen(OperationScopePrefix));
if (_next)
*_next = text + strlen(text);
return true;
}
break;
case '\0':
setId(SSTglobal, 0);
return true;
Expand Down Expand Up @@ -1761,6 +1788,17 @@ void StatsScopeId::setDfuWorkunitId(const char * _name)
scopeType = SSTdfuworkunit;
name.set(_name);
}
void StatsScopeId::setSectionId(const char * _name)
{
scopeType = SSTsection;
name.set(_name);
}
void StatsScopeId::setOperationId(const char * _name)
{
scopeType = SSToperation;
name.set(_name);
}

//--------------------------------------------------------------------------------------------------------------------

enum
Expand Down
3 changes: 3 additions & 0 deletions system/jlib/jstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class jlib_decl StatsScopeId
void setWorkflowId(unsigned _id);
void setChildGraphId(unsigned _id);
void setDfuWorkunitId(const char * _name);
void setSectionId(const char * _name);
void setOperationId(const char * _name);

int compare(const StatsScopeId & other) const;

bool operator == (const StatsScopeId & other) const { return matches(other); }
Expand Down

0 comments on commit 5fafb3f

Please sign in to comment.