Skip to content

Commit 7c8e343

Browse files
committed
DPL: account for IO time correctly
Now that we lazily read into the shared memory directly, we need to compute the time delta up to the destruction of the FragmentToBatch, which is where the actual reading ultimately finishes.
1 parent ce065f9 commit 7c8e343

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

Framework/AnalysisSupport/src/DataInputDirector.cxx

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -387,18 +387,53 @@ int DataInputDescriptor::findDFNumber(int file, std::string dfName)
387387
return it - dfList.begin();
388388
}
389389

390+
struct CalculateDelta {
391+
CalculateDelta(uint64_t& target)
392+
: mTarget(target)
393+
{
394+
start = uv_hrtime();
395+
}
396+
~CalculateDelta()
397+
{
398+
if (!active) {
399+
return;
400+
}
401+
O2_SIGNPOST_ACTION(reader_memory_dump, [](void*) {
402+
void (*dump_)(const char*);
403+
if (void* sym = dlsym(nullptr, "igprof_dump_now")) {
404+
dump_ = __extension__(void (*)(const char*)) sym;
405+
if (dump_) {
406+
std::string filename = fmt::format("reader-memory-dump-{}.gz", uv_hrtime());
407+
dump_(filename.c_str());
408+
}
409+
}
410+
});
411+
mTarget += (uv_hrtime() - start);
412+
}
413+
414+
void deactivate() {
415+
active = false;
416+
}
417+
418+
bool active = true;
419+
uint64_t& mTarget;
420+
uint64_t start;
421+
uint64_t stop;
422+
};
423+
390424
bool DataInputDescriptor::readTree(DataAllocator& outputs, header::DataHeader dh, int counter, int numTF, std::string treename, size_t& totalSizeCompressed, size_t& totalSizeUncompressed)
391425
{
392-
auto ioStart = uv_hrtime();
393-
426+
CalculateDelta t(mIOTime);
394427
auto folder = getFileFolder(counter, numTF);
395428
if (!folder.filesystem()) {
429+
t.deactivate();
396430
return false;
397431
}
398432

399433
auto rootFS = std::dynamic_pointer_cast<TFileFileSystem>(folder.filesystem());
400434

401435
if (!rootFS) {
436+
t.deactivate();
402437
throw std::runtime_error(fmt::format(R"(Not a TFile filesystem!)"));
403438
}
404439
// FIXME: Ugly. We should detect the format from the treename, good enough for now.
@@ -420,6 +455,7 @@ bool DataInputDescriptor::readTree(DataAllocator& outputs, header::DataHeader dh
420455
// FIXME: we should distinguish between an actually missing object and one which has a non compatible
421456
// format.
422457
if (!format) {
458+
t.deactivate();
423459
LOGP(debug, "Could not find tree {}. Trying in parent file.", fullpath.path());
424460
auto parentFile = getParentFile(counter, numTF, treename);
425461
if (parentFile != nullptr) {
@@ -460,19 +496,6 @@ bool DataInputDescriptor::readTree(DataAllocator& outputs, header::DataHeader dh
460496
f2b->setLabel(treename.c_str());
461497
f2b->fill(datasetSchema, format);
462498

463-
mIOTime += (uv_hrtime() - ioStart);
464-
465-
O2_SIGNPOST_ACTION(reader_memory_dump, [](void*) {
466-
void (*dump_)(const char*);
467-
if (void* sym = dlsym(nullptr, "igprof_dump_now")) {
468-
dump_ = __extension__(void (*)(const char*)) sym;
469-
if (dump_) {
470-
std::string filename = fmt::format("reader-memory-dump-{}.gz", uv_hrtime());
471-
dump_(filename.c_str());
472-
}
473-
}
474-
});
475-
476499
return true;
477500
}
478501

@@ -820,7 +843,8 @@ bool DataInputDirector::readTree(DataAllocator& outputs, header::DataHeader dh,
820843
treename = aod::datamodel::getTreeName(dh);
821844
}
822845

823-
return didesc->readTree(outputs, dh, counter, numTF, treename, totalSizeCompressed, totalSizeUncompressed);
846+
auto result = didesc->readTree(outputs, dh, counter, numTF, treename, totalSizeCompressed, totalSizeUncompressed);
847+
return result;
824848
}
825849

826850
void DataInputDirector::closeInputFiles()

0 commit comments

Comments
 (0)