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

Improve exception safety of RDataSource range processing #17975

Merged
Merged
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
3 changes: 3 additions & 0 deletions tree/dataframe/inc/ROOT/RDF/RLoopManager.hxx
Original file line number Diff line number Diff line change
@@ -97,6 +97,8 @@ public:
}
};

struct RDSRangeRAII;

} // namespace RDF
} // namespace Internal
} // namespace ROOT
@@ -126,6 +128,7 @@ class RLoopManager : public RNodeBase {
};

friend struct RCallCleanUpTask;
friend struct ROOT::Internal::RDF::RDSRangeRAII;

std::vector<RDFInternal::RActionBase *> fBookedActions; ///< Non-owning pointers to actions to be run
std::vector<RDFInternal::RActionBase *> fRunActions; ///< Non-owning pointers to actions already run
19 changes: 13 additions & 6 deletions tree/dataframe/src/RLoopManager.cxx
Original file line number Diff line number Diff line change
@@ -721,15 +721,25 @@ struct DSRunRAII {
};
} // namespace

struct ROOT::Internal::RDF::RDSRangeRAII {
ROOT::Detail::RDF::RLoopManager &fLM;
unsigned int fSlot;
RDSRangeRAII(ROOT::Detail::RDF::RLoopManager &lm, unsigned int slot, ULong64_t firstEntry) : fLM(lm), fSlot(slot)
{
fLM.InitNodeSlots(nullptr, fSlot);
fLM.GetDataSource()->InitSlot(fSlot, firstEntry);
}
~RDSRangeRAII() { fLM.GetDataSource()->FinalizeSlot(fSlot); }
};

/// Run event loop over data accessed through a DataSource, in sequence.
void RLoopManager::RunDataSource()
{
assert(fDataSource != nullptr);
DSRunRAII _{*fDataSource};
auto ranges = fDataSource->GetEntryRanges();
while (!ranges.empty() && fNStopsReceived < fNChildren) {
InitNodeSlots(nullptr, 0u);
fDataSource->InitSlot(0u, 0ull);
RDSRangeRAII __{*this, 0u, 0ull};
RCallCleanUpTask cleanup(*this);
try {
for (const auto &range : ranges) {
@@ -746,7 +756,6 @@ void RLoopManager::RunDataSource()
std::cerr << "RDataFrame::Run: event loop was interrupted\n";
throw;
}
fDataSource->FinalizeSlot(0u);
ranges = fDataSource->GetEntryRanges();
}
}
@@ -763,9 +772,8 @@ void RLoopManager::RunDataSourceMT()
auto runOnRange = [this, &slotStack](const std::pair<ULong64_t, ULong64_t> &range) {
ROOT::Internal::RSlotStackRAII slotRAII(slotStack);
const auto slot = slotRAII.fSlot;
InitNodeSlots(nullptr, slot);
RDSRangeRAII _{*this, slot, range.first};
RCallCleanUpTask cleanup(*this, slot);
fDataSource->InitSlot(slot, range.first);
const auto start = range.first;
const auto end = range.second;
R__LOG_DEBUG(0, RDFLogChannel()) << LogRangeProcessing({fDataSource->GetLabel(), start, end, slot});
@@ -779,7 +787,6 @@ void RLoopManager::RunDataSourceMT()
std::cerr << "RDataFrame::Run: event loop was interrupted\n";
throw;
}
fDataSource->FinalizeSlot(slot);
};

DSRunRAII _{*fDataSource};
Loading