From 5fafb3f9339205691efc2a8382c0a42a1da84819 Mon Sep 17 00:00:00 2001 From: Gavin Halliday Date: Thu, 4 Jan 2024 10:47:02 +0000 Subject: [PATCH] HPCC-29790 Rationalise the way stages are represented in scopes Signed-off-by: Gavin Halliday --- system/jlib/jstatcodes.h | 2 ++ system/jlib/jstats.cpp | 40 +++++++++++++++++++++++++++++++++++++++- system/jlib/jstats.h | 3 +++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/system/jlib/jstatcodes.h b/system/jlib/jstatcodes.h index ea66d4f6a24..0f264acc92f 100644 --- a/system/jlib/jstatcodes.h +++ b/system/jlib/jstatcodes.h @@ -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) diff --git a/system/jlib/jstats.cpp b/system/jlib/jstats.cpp index 989b601b006..39d1b1f1afa 100644 --- a/system/jlib/jstats.cpp +++ b/system/jlib/jstats.cpp @@ -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) { @@ -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: @@ -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)])) @@ -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; @@ -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 diff --git a/system/jlib/jstats.h b/system/jlib/jstats.h index 4fa1f8e08f0..187cb9a2f11 100644 --- a/system/jlib/jstats.h +++ b/system/jlib/jstats.h @@ -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); }