diff --git a/tree/treeplayer/src/TTreeProcessorMP.cxx b/tree/treeplayer/src/TTreeProcessorMP.cxx index c40f57f790386..e8cacb22575dd 100644 --- a/tree/treeplayer/src/TTreeProcessorMP.cxx +++ b/tree/treeplayer/src/TTreeProcessorMP.cxx @@ -14,6 +14,9 @@ #include "ROOT/TTreeProcessorMP.hxx" #include "TMPWorkerTree.h" +#include +static const std::thread::id MAIN_THREAD_ID = std::this_thread::get_id(); + ////////////////////////////////////////////////////////////////////////// /// /// \class ROOT::TTreeProcessorMP @@ -104,6 +107,14 @@ TList *TTreeProcessorMP::Process(TTree &tree, TSelector &selector, TEntryList &e jFirst = 0; } + // Warn about forking of already threaded program + if (std::this_thread::get_id() != MAIN_THREAD_ID) { + Warning("Process", + "multiprocessing from an already multi-threaded program " + "(first thread '%zu' vs current thread id '%zu') might lead to inefficient forking", + std::hash{}(MAIN_THREAD_ID), std::hash{}(std::this_thread::get_id())); + } + //prepare environment Reset(); UInt_t nWorkers = GetNWorkers();