-
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-29817 Eliminate seeks, scans & wildseeks from KeyStatsCollector and track cache stats in hthor #17541
Conversation
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 in good in general, please see feedback.
common/thorhelper/thorcommon.hpp
Outdated
@@ -672,6 +673,108 @@ class THORHELPER_API IndirectCodeContext : implements ICodeContext | |||
protected: | |||
ICodeContext * ctx; | |||
}; | |||
class CThorBaseContextLogger : public CSimpleInterfaceOf<IContextLogger> |
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/formatting: we norrmally have a new line before a new class definition.
common/thorhelper/thorcommon.hpp
Outdated
mutable CRuntimeStatisticCollection stats; | ||
|
||
public: | ||
CThorBaseContextLogger() : stats(jhtreeCacheStatistics) |
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.
To make this a more generliazed stats logger context, it would be good to rename it (as it's not just 'Thor') - call it something like CStatsContextLogger, and pass in the mapping:
CThorBaseContextLogger(CRuntimeStatisticCollection &_mapping) : mapping(_mapping)
common/thorhelper/thorcommon.hpp
Outdated
{ | ||
va_list args; | ||
va_start(args, format); | ||
CTXLOGva(MCdebugProgress, unknownJob, NoLogMsgCode, format, args); |
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 worth passing in a LogMsgJobInfo & to the ctor and using here and in logOperatorExceptionVA below.
then can the CThorContextLogger::CTXLOG and CThorContextLogger::logOperatorExceptionVA can be deleted.
ecl/hthor/hthorkey.cpp
Outdated
@@ -3036,11 +3012,11 @@ class KeyedLookupPartHandler : extends ThreadedPartHandler<MatchSet>, implements | |||
Owned<IKeyManager> manager; | |||
IAgentContext &agent; | |||
DistributedKeyLookupHandler * tlk; | |||
|
|||
CHThorContextLogger &contextLogger; |
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: unless needs to be an implementation reference, better if it was an interface reference (IContextLogger &)
Declaring it as a CHThorContextLogger makes it look like it needs to / code relies on it.
and similarly in a few other places
ecl/hthor/hthor.ipp
Outdated
// improvement: override constructor to store setHttpIdHeaderNames, override CTXLOG & logOperatorExceptionVA to log LogMsgJobInfo | ||
class CHThorContextLogger : public CThorBaseContextLogger | ||
{ | ||
}; |
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.
With a rename of the base to CStatsContextLogger (+ passing in mapping + job),
I think this can be deleted in favour of using CStatsContextLogger.
Thor's derivation can remain for it's specialization if need be.
ecl/hthor/hthorkey.cpp
Outdated
unsigned postFiltered; | ||
unsigned wildseeks; | ||
CHThorContextLogger contextLogger; |
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.
Does there need to be a logger per activity type that uses one..
Could there just be 1 in the agent (which is how it's done in roxie) ?
roxie/ccd/ccdcontext.cpp
Outdated
@@ -1179,7 +1179,7 @@ class InlineXmlDataReader : public WorkUnitRowReaderBase | |||
|
|||
//--------------------------------------------------------------------------------------- | |||
|
|||
static const StatisticsMapping graphStatistics({}); | |||
static const StatisticsMapping roxieGraphStatistics({}); |
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.
no need to rename, related to comment re. moving Thor mapping (back to Thor code),
unsigned __int64 seeks = stats.getStatisticValue(StNumIndexSeeks); | ||
unsigned __int64 scans = stats.getStatisticValue(StNumIndexScans); | ||
unsigned __int64 skips = stats.getStatisticValue(StNumIndexSkips); | ||
logctx.CTXLOG("Indexread returning result set %d rows from %" I64F"u seeks, %" I64F"u scans, %" I64F"u skips", processed-processedBefore, seeks, scans, skips); |
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.
may not be trivial, but wondering if the 4 incidents of this type of code ( I think they're same with different messages?) could be commoned up.
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.
Possibly but would prefer to keep as it is to stop the scope of this jira from creeping.
thorlcr/thorutil/thormisc.hpp
Outdated
public: | ||
CThorContextLogger() : stats(jhtreeCacheStatistics) | ||
CThorContextLogger() | ||
{ | ||
if (globals->hasProp("@httpGlobalIdHeader")) |
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.
perhaps pass a IPropertyTree in to CStatsContextLogger too and move this code there.
a63c70a
to
2b74f3b
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 - made 1st review pass at this, it does look a lot cleaner overall, but I think IContextLogger/IRoxieContextLogger and their implementations need looking at/refactoring.
See comments.
system/jlib/jlog.hpp
Outdated
const LogMsgJobInfo & logMsgJobInfo; | ||
LogTrace logTrace; | ||
public: | ||
IContextLogger(const IPropertyTree *cfg, const LogMsgJobInfo & _logMsgJobInfo=unknownJob) : logMsgJobInfo(_logMsgJobInfo) |
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.
interfaces should really not have concrete implementations.
I realize IContextLogger already had some, but with a ctor it looks pointedly wrong.
Whatever is implementing IContextLogger should have the ctor and implement the concrete implementations.
In this case, if we want a default implementation with a ctor, there should be a CDefaultContextLogger or similar, and other implementations can derive from it.
I see that IRoxieContextLogger also broke this rule, but given a default IContextLogger implementation, implementations of IRoxieContextLogger can also derive from that default implementation and override what they want to (i.e. the "ContextLogger" implementation in ccd.hpp)
common/thorhelper/roxiehelper.ipp
Outdated
@@ -59,6 +59,7 @@ enum TracingCategory | |||
class LogItem; | |||
interface IRoxieContextLogger : extends IContextLogger | |||
{ | |||
IRoxieContextLogger(IPropertyTree *cfg) : IContextLogger(cfg) {} |
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.
see related comments in jlog.hpp re. IContextLogger.
interfaces should really not have constructors and concrete implementations.
roxie/ccd/ccd.hpp
Outdated
ContextLogger(const ContextLogger &); // Disable copy constructor | ||
public: | ||
IMPLEMENT_IINTERFACE; | ||
|
||
ContextLogger() : stats(accumulatedStatistics, true) | ||
ContextLogger() : IRoxieContextLogger(topology), stats(accumulatedStatistics, true) |
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.
see other comments re. interfaces shouldn't implement.
I know this is not entirely new, but looks very wrong now with interface taking ctor.
There should instead be a base class that implements IRoxieContextLogger and inherit from it.
4a8c9b5
to
a72b6ae
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 - looks cleaner, but it would best if this non-trivial refactoring of these IContextLogger and IRoxieContextLogger implementations were in a separate PR.
And I think can be done without removing roxie's extended interface (IRoxieContextLogger), which should also be pure.
The implementations could share a common base, either by the concrete implementations implementing the pure methods and calling the common base methods, or to avoid all the trivial 1-liner method implementations, the base class could be a template class, that takes either IContextLogger or IRoxieContextLogger, e.g.:
template class <INTERFACE>
class CDefaultContextLogger : public CInterfaceOf<INTERFACE>
{
..
}
class CBaseRoxieContextLogger : public CDefaultContextLogger<IRoxieContextLogger>
{
..
}
That way, the roxie code will not need changing to use a class and can continue to use IRoxieContextLogger (which will now be purely abstract).
a167289
to
5260a0a
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.
I don't see any problems.
@shamser the smoke test is failing because it fails to build. |
b10392c
to
ee606f3
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 - looks good, 2 minor comments
common/thorhelper/thorcommon.hpp
Outdated
class CStatsContextLogger : public CSimpleInterfaceOf<IContextLogger> | ||
{ | ||
protected: | ||
const LogMsgJobInfo & job; |
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.
it may not make any practical difference (if the passed in LogMsgJobInfo stay in scope/aren't destroyed),
but I think when keeping a LogMsgJobInfo we normally copy it (only by reference when not taking a copy/referenced copy) - e.g. see LogMsg class member.
system/jlib/jstats.h
Outdated
@@ -944,4 +943,6 @@ class jlib_decl RuntimeStatisticTarget : implements IStatisticTarget | |||
extern jlib_decl StringBuffer & formatMoney(StringBuffer &out, unsigned __int64 value); | |||
extern jlib_decl stat_type aggregateStatistic(StatisticKind kind, IStatisticCollection * statsCollection); | |||
|
|||
extern jlib_decl const StatisticsMapping jhtreeCacheStatistics; |
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: would be easier to find if moved with the other jstats.h StatisticMappings (around line 494)
fc1c60a
to
cdfe748
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 - looks good, please squash.
@shamser needs rebasing before it can be merged |
…and track cache stats in hthor Signed-off-by: Shamser Ahmed <[email protected]>
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
Owned<ISpan> activeSpan; | ||
mutable CRuntimeStatisticCollection stats; | ||
public: | ||
CStatsContextLogger(const CRuntimeStatisticCollection &_mapping, const LogMsgJobInfo & _job=unknownJob) : job(_job), stats(_mapping) {} |
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/formatting: double space before &_mapping
public: | ||
CStatsContextLogger(const CRuntimeStatisticCollection &_mapping, const LogMsgJobInfo & _job=unknownJob) : job(_job), stats(_mapping) {} | ||
|
||
virtual void CTXLOGva(const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char *format, va_list args) const override __attribute__((format(printf,5,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.
trivial/formatting: double space before __attribute
8d6574d
into
hpcc-systems:candidate-9.4.x
…
Type of change:
Checklist:
Smoketest:
Testing: