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-29880 Serialize index write's jhtree and disk io stats regularly #19385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions system/jhtree/keybuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ class CKeyBuilder : public CInterfaceOf<IKeyBuilder>

private:
unsigned __int64 duplicateCount;
unsigned __int64 numLeaves = 0;
unsigned __int64 numBranches = 0;
unsigned __int64 numBlobs = 0;
RelaxedAtomic<__uint64> numLeaves{0};
RelaxedAtomic<__uint64> numBranches{0};
RelaxedAtomic<__uint64> numBlobs{0};
__uint64 partitionFieldMask = 0;
CWriteNode *activeNode = nullptr;
CBlobWriteNode *activeBlobNode = nullptr;
Expand Down
43 changes: 33 additions & 10 deletions thorlcr/activities/indexwrite/thindexwriteslave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt
Owned<IRowStream> myInputStream;
Owned<IPropertyTree> metadata;
Linked<IEngineRowAllocator> outRowAllocator;
mutable CriticalSection builderFileCS; // protect changes to both builder and builderFileIO (they should be in sync)

bool buildTlk, active;
bool sizeSignalled;
Expand All @@ -54,9 +55,9 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt

size32_t lastRowSize, firstRowSize, maxRecordSizeSeen, keyedSize;
unsigned __int64 duplicateKeyCount;
unsigned __int64 numLeafNodes = 0;
unsigned __int64 numBranchNodes = 0;
unsigned __int64 numBlobNodes = 0;
mutable unsigned __int64 numLeafNodes = 0;
mutable unsigned __int64 numBranchNodes = 0;
mutable unsigned __int64 numBlobNodes = 0;
offset_t offsetBranches = 0;
offset_t uncompressedSize = 0;
offset_t originalBlobSize = 0;
Expand All @@ -73,6 +74,7 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt
unsigned partCrc, tlkCrc;
mptag_t mpTag2;
Owned<IRowServer> rowServer;
bool isDoingTlk = false;

void init()
{
Expand Down Expand Up @@ -153,6 +155,7 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt
}
void open(IPartDescriptor &partDesc, bool isTlk)
{
isDoingTlk = isTlk;
StringBuffer partFname;
getPartFilename(partDesc, 0, partFname);
bool compress=false;
Expand Down Expand Up @@ -212,12 +215,15 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt
if (metadata->getPropBool("_useTrailingHeader", true))
flags |= USE_TRAILING_HEADER;
unsigned twFlags = isUrl(partFname) ? TW_Direct : TW_RenameToPrimary;
builderIFileIO.setown(createMultipleWrite(this, partDesc, 0, twFlags, compress, NULL, this, &abortSoon));
Owned<IFileIOStream> out = createBufferedIOStream(builderIFileIO, 0x100000);
if (!needsSeek)
out.setown(createNoSeekIOStream(out));
maxRecordSizeSeen = 0;
builder.setown(createKeyBuilder(out, flags, maxDiskRecordSize, nodeSize, helper->getKeyedSize(), isTlk ? 0 : totalCount, helper, defaultIndexCompression, !isTlk, isTlk));
{
CriticalBlock b(builderFileCS);
builderIFileIO.setown(createMultipleWrite(this, partDesc, 0, twFlags, compress, NULL, this, &abortSoon));
Owned<IFileIOStream> out = createBufferedIOStream(builderIFileIO, 0x100000);
if (!needsSeek)
out.setown(createNoSeekIOStream(out));
maxRecordSizeSeen = 0;
builder.setown(createKeyBuilder(out, flags, maxDiskRecordSize, nodeSize, helper->getKeyedSize(), isTlk ? 0 : totalCount, helper, defaultIndexCompression, !isTlk, isTlk));
}
}
void buildLayoutMetadata(Owned<IPropertyTree> & metadata)
{
Expand Down Expand Up @@ -261,6 +267,7 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt
}
try
{
CriticalBlock b(builderFileCS);
metadata.clear();
builder.clear();
if (builderIFileIO)
Expand Down Expand Up @@ -613,7 +620,10 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt
}
virtual void processDone(MemoryBuffer &mb) override
{
builder.clear();
{
CriticalBlock b(builderFileCS);
builder.clear();
}
if (refactor && !active)
return;
rowcount_t _processed = processed & THORDATALINK_COUNT_MASK;
Expand Down Expand Up @@ -699,6 +709,19 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt
virtual void gatherActiveStats(CRuntimeStatisticCollection &activeStats) const
{
PARENT::gatherActiveStats(activeStats);
{
CriticalBlock b(builderFileCS);
if (builderIFileIO)
{
mergeStats(activeStats, builderIFileIO, diskWriteRemoteStatistics);
if (builder && !isDoingTlk)
{
numLeafNodes = builder->getNumLeafNodes();
numBranchNodes = builder->getNumBranchNodes();
numBlobNodes = builder->getNumBlobNodes();
}
}
}
activeStats.setStatistic(StPerReplicated, replicateDone);
activeStats.setStatistic(StNumLeafCacheAdds, numLeafNodes);
activeStats.setStatistic(StNumNodeCacheAdds, numBranchNodes);
Expand Down
Loading