-
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-29880 Serialize index write's jhtree and disk io stats regularly #19385
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,11 +40,11 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt | |
StringAttr logicalFilename; | ||
Owned<IPartDescriptor> partDesc, tlkDesc; | ||
IHThorIndexWriteArg *helper; | ||
Owned <IKeyBuilder> builder; | ||
OwnedIFileIO builderIFileIO; | ||
Owned<IKeyBuilder> builder; | ||
Owned<IRowStream> myInputStream; | ||
Owned<IPropertyTree> metadata; | ||
Linked<IEngineRowAllocator> outRowAllocator; | ||
mutable CriticalSection builderCS; | ||
|
||
bool buildTlk, active; | ||
bool sizeSignalled; | ||
|
@@ -54,9 +54,6 @@ 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; | ||
offset_t offsetBranches = 0; | ||
offset_t uncompressedSize = 0; | ||
offset_t originalBlobSize = 0; | ||
|
@@ -212,12 +209,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)); | ||
OwnedIFileIO builderIFileIO = 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(builderCS); | ||
builder.setown(createKeyBuilder(out, flags, maxDiskRecordSize, nodeSize, helper->getKeyedSize(), isTlk ? 0 : totalCount, helper, defaultIndexCompression, !isTlk, isTlk)); | ||
} | ||
} | ||
void buildLayoutMetadata(Owned<IPropertyTree> & metadata) | ||
{ | ||
|
@@ -235,16 +235,24 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt | |
{ | ||
if (builder) | ||
{ | ||
builder->finish(metadata, &crc, maxRecordSizeSeen); | ||
if (!isTLK) | ||
// Clear out builder before merging builder stats into inactive stats | ||
// so that gatherActiveStatistics doesn't also merge builder stats. | ||
Owned<IKeyBuilder> tmpBuilder; | ||
{ | ||
CriticalBlock b(builderCS); | ||
tmpBuilder.setown(builder.getClear()); | ||
} | ||
if (tmpBuilder) | ||
{ | ||
duplicateKeyCount = builder->getDuplicateCount(); | ||
numLeafNodes = builder->getNumLeafNodes(); | ||
numBranchNodes = builder->getNumBranchNodes(); | ||
numBlobNodes = builder->getNumBlobNodes(); | ||
offsetBranches = builder->getOffsetBranches(); | ||
branchMemorySize = builder->getBranchMemorySize(); | ||
leafMemorySize = builder->getLeafMemorySize(); | ||
tmpBuilder->finish(metadata, &crc, maxRecordSizeSeen); | ||
if (!isTLK) | ||
{ | ||
duplicateKeyCount = tmpBuilder->getDuplicateCount(); | ||
offsetBranches = tmpBuilder->getOffsetBranches(); | ||
branchMemorySize = tmpBuilder->getBranchMemorySize(); | ||
leafMemorySize = tmpBuilder->getLeafMemorySize(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. future: for next JIRA, but these should be added as stats to indexWriteActivityStatistics, and collected via builder in a common way, and manual serialization/deserialization here and in master should be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
mergeStats(inactiveStats, tmpBuilder, indexWriteActivityStatistics); | ||
} | ||
} | ||
} | ||
|
@@ -259,22 +267,7 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt | |
abortSoon = true; | ||
e.setown(MakeActivityException(this, 0, "INDEXWRITE: Error closing file: %s - unknown exception", partFname.str())); | ||
} | ||
try | ||
{ | ||
metadata.clear(); | ||
builder.clear(); | ||
if (builderIFileIO) | ||
{ | ||
mergeStats(inactiveStats, builderIFileIO, diskWriteRemoteStatistics); | ||
builderIFileIO->close(); | ||
builderIFileIO.clear(); | ||
} | ||
} | ||
catch (IException *_e) | ||
{ | ||
ActPrintLog(_e, "Error closing file: %s", partFname.str()); | ||
e.setown(_e); | ||
} | ||
metadata.clear(); | ||
if (abortSoon) | ||
removeFiles(partDesc); | ||
if (e) | ||
|
@@ -613,7 +606,10 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt | |
} | ||
virtual void processDone(MemoryBuffer &mb) override | ||
{ | ||
builder.clear(); | ||
{ | ||
CriticalBlock b(builderCS); | ||
builder.clear(); | ||
} | ||
if (refactor && !active) | ||
return; | ||
rowcount_t _processed = processed & THORDATALINK_COUNT_MASK; | ||
|
@@ -630,10 +626,9 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt | |
ifile->getTime(&createTime, &modifiedTime, &accessedTime); | ||
modifiedTime.serialize(mb); | ||
mb.append(partCrc); | ||
|
||
mb.append(numLeafNodes); | ||
mb.append(numBlobNodes); | ||
mb.append(numBranchNodes); | ||
mb.append(inactiveStats.getStatisticValue(StNumLeafCacheAdds)); | ||
mb.append(inactiveStats.getStatisticValue(StNumBlobCacheAdds)); | ||
mb.append(inactiveStats.getStatisticValue(StNumNodeCacheAdds)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. future: Is there a separate JIRA to remove these manual serializations? ..since they will now be serialized as part of the activity stats. and the deserializing and manual setting of @numLeafNodes, @numBranchNodes, @numBlobNodes is superfluous. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to change it in this PR as they are used in few other places. Yes, I can remove these in a future jira. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
mb.append(offsetBranches); | ||
mb.append(uncompressedSize); | ||
mb.append(originalBlobSize); | ||
|
@@ -699,10 +694,12 @@ class IndexWriteSlaveActivity : public ProcessSlaveActivity, public ILookAheadSt | |
virtual void gatherActiveStats(CRuntimeStatisticCollection &activeStats) const | ||
{ | ||
PARENT::gatherActiveStats(activeStats); | ||
{ | ||
CriticalBlock b(builderCS); | ||
if (builder) | ||
mergeStats(activeStats, builder, indexWriteActivityStatistics); | ||
} | ||
activeStats.setStatistic(StPerReplicated, replicateDone); | ||
activeStats.setStatistic(StNumLeafCacheAdds, numLeafNodes); | ||
activeStats.setStatistic(StNumNodeCacheAdds, numBranchNodes); | ||
activeStats.setStatistic(StNumBlobCacheAdds, numBlobNodes); | ||
} | ||
|
||
// ICopyFileProgress | ||
|
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.
future: add other stats (offsetBranches, branchMemorySize, leadMemorySize) to stats mapping and collect these via gather stats too.
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.
Future: https://hpccsystems.atlassian.net/browse/HPCC-33279