Skip to content
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-31511 Avoid keeping the workunit graphs in memory #18519

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions common/workunit/workunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10411,8 +10411,11 @@ IPropertyTree * CLocalWUGraph::getXGMMLTreeRaw() const
return p->getPropTree("xgmml");
}

bool workunitGraphCacheEnabled = true;

IPropertyTree * CLocalWUGraph::getXGMMLTree(bool doMergeProgress, bool doFormatStats) const
{
Owned<IPropertyTree> localGraph;
{
CriticalBlock block(owner.crit);
if (!graph)
Expand All @@ -10421,18 +10424,22 @@ IPropertyTree * CLocalWUGraph::getXGMMLTree(bool doMergeProgress, bool doFormatS
// daliadmin can retrospectively compress existing graphs, so need to check for all versions
MemoryBuffer mb;
if (p->getPropBin("xgmml/graphBin", mb))
graph.setown(createPTree(mb, ipt_lowmem));
localGraph.setown(createPTree(mb, ipt_lowmem));
else
graph.setown(p->getBranch("xgmml/graph"));
if (!graph)
localGraph.setown(p->getBranch("xgmml/graph"));
if (!localGraph)
return NULL;
if (workunitGraphCacheEnabled)
graph.set(localGraph);
}
else
localGraph.set(graph);
}
if (!doMergeProgress)
return graph.getLink();
return localGraph.getClear();
else
{
Owned<IPropertyTree> copy = createPTreeFromIPT(graph, ipt_lowmem);
Owned<IPropertyTree> copy = workunitGraphCacheEnabled ? createPTreeFromIPT(localGraph, ipt_lowmem) : LINK(localGraph) ;
Owned<IConstWUGraphProgress> progress = owner.getGraphProgress(p->queryProp("@name"));
if (progress)
{
Expand Down
1 change: 1 addition & 0 deletions common/workunit/workunit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1788,5 +1788,6 @@ extern WORKUNIT_API void executeThorGraph(const char * graphName, IConstWorkUnit
extern WORKUNIT_API TraceFlags loadTraceFlags(IConstWorkUnit * wu, const std::initializer_list<TraceOption> & y, TraceFlags dft);

extern WORKUNIT_API bool executeGraphOnLingeringThor(IConstWorkUnit &workunit, unsigned wfid, const char *graphName);
extern WORKUNIT_API bool workunitGraphCacheEnabled;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of exported variables. We tend to provide get()/set() functions everywhere else except for roxie. I may not care enough to avoid merging though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can come up with a good reason, I don't mind changing. But there are plenty of other exported variables around...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are very few, except for roxie. (E.g. I don't think there are any in this file.)
It generates slightly worse code (an extra indirect) - not significant in this case, but in general worth avoiding. (Thread local access code is much worse...)


#endif
1 change: 1 addition & 0 deletions ecl/eclagent/eclagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3593,6 +3593,7 @@ extern int HTHOR_API eclagent_main(int argc, const char *argv[], Owned<ILocalWor
printStart(argc, argv);
DBGLOG("Build %s", hpccBuildInfo.buildTag);
}
workunitGraphCacheEnabled = agentTopology->getPropBool("expert/@workunitGraphCacheEnabled", workunitGraphCacheEnabled);

// Extract any params into stored - primarily for standalone case but handy for debugging eclagent sometimes too
Owned<IPropertyTree> query;
Expand Down
2 changes: 2 additions & 0 deletions esp/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ include_directories (
./../../system/jlib
./../bindings/http/platform
./../../common/environment
./../../common/workunit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected a need to add workunit to the link libraries as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it builds without - probably because one of the libraries included already links to it. But I will add.

./../../system/mp
./../../fs/dafsclient
${CMAKE_BINARY_DIR}
Expand All @@ -61,6 +62,7 @@ target_link_libraries ( esp
hrpc
remote
dalibase
workunit
)

if (NOT CONTAINERIZED)
Expand Down
3 changes: 3 additions & 0 deletions esp/platform/espp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include "dafdesc.hpp"

#include "jmetrics.hpp"
#include "workunit.hpp"

using namespace hpccMetrics;

void CEspServer::sendSnmpMessage(const char* msg) { throwUnexpected(); }
Expand Down Expand Up @@ -488,6 +490,7 @@ int init_main(int argc, const char* argv[])
Owned<IPropertyTree> procpt = NULL;
if (envpt)
{
workunitGraphCacheEnabled = envpt->getPropBool("expert/@workunitGraphCacheEnabled", workunitGraphCacheEnabled);
envpt->addProp("@config", cfgfile);
StringBuffer xpath;
if (procname==NULL || strcmp(procname, ".")==0)
Expand Down
2 changes: 2 additions & 0 deletions roxie/ccd/ccdmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,8 @@ int CCD_API roxie_main(int argc, const char *argv[], const char * defaultYaml)
else
multicastTTL = ttlTmp;

workunitGraphCacheEnabled = topology->getPropBool("expert/@workunitGraphCacheEnabled", workunitGraphCacheEnabled);

indexReadChunkSize = topology->getPropInt("@indexReadChunkSize", 60000);
numAgentThreads = topology->getPropInt("@agentThreads", topology->getPropInt("@slaveThreads", 30)); // legacy name
numServerThreads = topology->getPropInt("@serverThreads", 30);
Expand Down
2 changes: 1 addition & 1 deletion thorlcr/master/thgraphmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ bool CJobManager::execute(IConstWorkUnit *workunit, const char *wuid, const char
wu->setDebugAgentListenerIP(sb); //tells debugger what IP to write commands to
wu->setDebugAgentListenerPort(debugListener->getPort());
}

workunitGraphCacheEnabled = getExpertOptBool("workunitGraphCacheEnabled", workunitGraphCacheEnabled);
return doit(workunit, graphName, agentep);
}
catch (IException *e)
Expand Down
1 change: 1 addition & 0 deletions thorlcr/slave/thslavemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ static bool RegisterSelf(SocketEndpoint &masterEp)
getExpertOptPath(nullptr, xpath); // 'expert' in container world, or 'Debug' in bare-metal
ensurePTree(globals, xpath);
unsigned numStrands, blockSize;
workunitGraphCacheEnabled = getExpertOptBool("workunitGraphCacheEnabled", workunitGraphCacheEnabled);
getExpertOptPath("forceNumStrands", xpath.clear());
if (globals->hasProp(xpath))
numStrands = globals->getPropInt(xpath);
Expand Down
Loading