Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-13 03:23:24

0001 #include "CondCore/CondDB/interface/ConnectionPool.h"
0002 #include "CondCore/CondDB/interface/IOVProxy.h"
0003 #include "CondCore/CondDB/interface/GTProxy.h"
0004 
0005 #include "CondCore/Utilities/interface/Utilities.h"
0006 #include "CondCore/Utilities/interface/CondDBImport.h"
0007 #include <iostream>
0008 #include <fstream>
0009 
0010 #include <atomic>
0011 #include <chrono>
0012 #include <memory>
0013 
0014 #include <boost/thread/mutex.hpp>
0015 #include "oneapi/tbb/parallel_for_each.h"
0016 #include "oneapi/tbb/global_control.h"
0017 
0018 namespace cond {
0019 
0020   using namespace persistency;
0021 
0022   class ConnectionPoolWrapper {
0023   public:
0024     ConnectionPoolWrapper(int authenticationSystem, const std::string& authenticationPath, bool debug);
0025     Session createSession(const std::string& connectionString);
0026     boost::mutex lock;
0027     ConnectionPool connPool;
0028   };
0029 
0030   class UntypedPayloadProxy {
0031   public:
0032     UntypedPayloadProxy();
0033 
0034     UntypedPayloadProxy(const UntypedPayloadProxy& rhs);
0035 
0036     UntypedPayloadProxy& operator=(const UntypedPayloadProxy& rhs);
0037 
0038     void init(Session session);
0039 
0040     void load(const std::string& tag);
0041 
0042     void reload();
0043 
0044     void reset();
0045 
0046     void disconnect();
0047 
0048     TimeType timeType() const;
0049     std::string tag() const;
0050     std::string payloadType() const;
0051 
0052     bool get(cond::Time_t targetTime, bool debug);
0053 
0054     size_t numberOfQueries() const;
0055 
0056     const std::vector<std::string>& history() const;
0057 
0058     const Binary& getBuffer() const;
0059     size_t getBufferSize() const;
0060 
0061     const Binary& getStreamerInfo() const;
0062 
0063     void setRecordInfo(const std::string& recName, const std::string& recLabel) {
0064       m_recName = recName;
0065       m_recLabel = recLabel;
0066     }
0067 
0068     const std::string recName() const { return m_recName; }
0069     const std::string recLabel() const { return m_recLabel; }
0070 
0071   private:
0072     struct pimpl {
0073       cond::Iov_t current;
0074       std::vector<std::string> history;
0075     };
0076 
0077     Session m_session;
0078     IOVProxy m_iov;
0079     std::shared_ptr<pimpl> m_data;
0080 
0081     Binary m_buffer;
0082     Binary m_streamerInfo;
0083 
0084     std::string m_recName;
0085     std::string m_recLabel;
0086 
0087   };  //  end class UntypedPayloadProxy
0088 
0089   class TestGTPerf : public cond::Utilities {
0090   public:
0091     TestGTPerf();
0092     int execute() override;
0093   };  // end class TestGTLoad
0094 
0095 }  // end namespace cond
0096 
0097 cond::ConnectionPoolWrapper::ConnectionPoolWrapper(int authenticationSystem,
0098                                                    const std::string& authenticationPath,
0099                                                    bool debug) {
0100   connPool.setAuthenticationSystem(authenticationSystem);
0101   if (!authenticationPath.empty())
0102     connPool.setAuthenticationPath(authenticationPath);
0103   if (debug)
0104     connPool.setMessageVerbosity(coral::Debug);
0105   connPool.configure();
0106 }
0107 
0108 cond::Session cond::ConnectionPoolWrapper::createSession(const std::string& connectionString) {
0109   Session s;
0110   {
0111     boost::mutex::scoped_lock slock(lock);
0112     s = connPool.createSession(connectionString);
0113   }
0114   return s;
0115 }
0116 
0117 cond::UntypedPayloadProxy::UntypedPayloadProxy() : m_session(), m_iov(), m_data(), m_buffer() {
0118   m_data.reset(new pimpl);
0119   m_data->current.clear();
0120 }
0121 
0122 cond::UntypedPayloadProxy::UntypedPayloadProxy(const UntypedPayloadProxy& rhs)
0123     : m_session(rhs.m_session), m_iov(rhs.m_iov), m_data(rhs.m_data), m_buffer(rhs.m_buffer) {}
0124 
0125 cond::UntypedPayloadProxy& cond::UntypedPayloadProxy::operator=(const cond::UntypedPayloadProxy& rhs) {
0126   m_session = rhs.m_session;
0127   m_iov = rhs.m_iov;
0128   m_data = rhs.m_data;
0129   m_buffer = rhs.m_buffer;
0130   return *this;
0131 }
0132 
0133 void cond::UntypedPayloadProxy::init(Session session) {
0134   m_session = session;
0135   reset();
0136 }
0137 
0138 void cond::UntypedPayloadProxy::load(const std::string& tag) {
0139   m_data->current.clear();
0140   m_session.transaction().start();
0141   m_iov = m_session.readIov(tag);
0142   m_session.transaction().commit();
0143 }
0144 
0145 void cond::UntypedPayloadProxy::reload() {
0146   std::string tag = m_iov.tagInfo().name;
0147   load(tag);
0148 }
0149 
0150 void cond::UntypedPayloadProxy::reset() {
0151   m_iov.reset();
0152   m_data->current.clear();
0153 }
0154 
0155 void cond::UntypedPayloadProxy::disconnect() { m_session.close(); }
0156 
0157 std::string cond::UntypedPayloadProxy::tag() const { return m_iov.tagInfo().name; }
0158 
0159 cond::TimeType cond::UntypedPayloadProxy::timeType() const { return m_iov.tagInfo().timeType; }
0160 
0161 std::string cond::UntypedPayloadProxy::payloadType() const { return m_iov.tagInfo().payloadType; }
0162 
0163 bool cond::UntypedPayloadProxy::get(cond::Time_t targetTime, bool debug) {
0164   bool loaded = false;
0165 
0166   //  check if the current iov loaded is the good one...
0167   if (targetTime < m_data->current.since || targetTime >= m_data->current.till) {
0168     // a new payload is required!
0169     if (debug)
0170       std::cout << " Searching tag " << m_iov.tagInfo().name << " for a valid payload for time=" << targetTime
0171                 << std::endl;
0172     m_session.transaction().start();
0173     auto iovs = m_iov.selectAll();
0174     auto iIov = iovs.find(targetTime);
0175     if (iIov == iovs.end())
0176       cond::throwException(std::string("Tag ") + m_iov.tagInfo().name +
0177                                ": No iov available for the target time:" + std::to_string(targetTime),
0178                            "UntypedPayloadProxy::get");
0179     m_data->current = *iIov;
0180 
0181     std::string payloadType("");
0182     loaded = m_session.fetchPayloadData(m_data->current.payloadId, payloadType, m_buffer, m_streamerInfo);
0183     m_session.transaction().commit();
0184 
0185     if (!loaded) {
0186       std::cout << "ERROR: payload with id " << m_data->current.payloadId << " could not be loaded." << std::endl;
0187     } else {
0188       if (debug)
0189         std::cout << "Loaded payload of type \"" << payloadType << "\" (" << m_buffer.size() << " bytes)" << std::endl;
0190     }
0191   }
0192   return loaded;
0193 }
0194 
0195 size_t cond::UntypedPayloadProxy::numberOfQueries() const { return m_iov.numberOfQueries(); }
0196 
0197 const std::vector<std::string>& cond::UntypedPayloadProxy::history() const { return m_data->history; }
0198 
0199 size_t cond::UntypedPayloadProxy::getBufferSize() const { return m_buffer.size(); }
0200 
0201 const cond::Binary& cond::UntypedPayloadProxy::getBuffer() const { return m_buffer; }
0202 
0203 const cond::Binary& cond::UntypedPayloadProxy::getStreamerInfo() const { return m_streamerInfo; }
0204 
0205 // ================================================================================
0206 
0207 class Timer {
0208 public:
0209   Timer(const std::string& nameIn) : name(nameIn) { reset(); }
0210   void reset() {
0211     start = std::chrono::steady_clock::now();
0212     intervals.clear();
0213     intervalNames.clear();
0214     interval("start");
0215   }
0216 
0217   void interval(const std::string& intName) {
0218     intervals.push_back(std::chrono::steady_clock::now());
0219     intervalNames.push_back(intName);
0220   }
0221 
0222   void fetchInt(size_t sizeIn) {
0223     fetchTime.push_back(std::chrono::steady_clock::now());
0224     fetchNum.push_back(sizeIn);
0225   }
0226   void deserInt(size_t sizeIn) {
0227     deserTime.push_back(std::chrono::steady_clock::now());
0228     deserNum.push_back(sizeIn);
0229   }
0230 
0231   void show(std::ostream& os = std::cout) {
0232     showIntervals(os);
0233     showFetchInfo(os);
0234     showDeserInfo(os);
0235   }
0236   void showIntervals(std::ostream& os = std::cout);
0237   void showFetchInfo(std::ostream& os = std::cout);
0238   void showDeserInfo(std::ostream& os = std::cout);
0239 
0240 private:
0241   std::string name;
0242 
0243   std::chrono::time_point<std::chrono::steady_clock> start;
0244 
0245   std::vector<std::chrono::time_point<std::chrono::steady_clock> > intervals;
0246   std::vector<std::string> intervalNames;
0247 
0248   std::vector<std::chrono::time_point<std::chrono::steady_clock> > fetchTime;
0249   std::vector<int> fetchNum;
0250 
0251   std::vector<std::chrono::time_point<std::chrono::steady_clock> > deserTime;
0252   std::vector<int> deserNum;
0253 };
0254 
0255 void Timer::showIntervals(std::ostream& os) {
0256   os << std::endl;
0257   os << "Serialization type: " << name << std::endl;
0258   for (size_t i = 1; i < intervals.size(); i++) {
0259     os << intervalNames[i] << " : "
0260        << std::chrono::duration<double, std::milli>(intervals[i] - intervals[i - 1]).count() << " msec. " << std::endl;
0261   }
0262   os << "\noverall time elapsed"
0263      << " : " << std::chrono::duration<double, std::milli>(intervals[intervals.size() - 1] - intervals[0]).count()
0264      << " msec. " << std::endl;
0265   os << std::endl;
0266 }
0267 
0268 void Timer::showFetchInfo(std::ostream& os) {
0269   os << std::endl;
0270   os << "Serialization type: " << name << std::endl;
0271   if (fetchTime.empty()) {
0272     os << "No fetch info available." << std::endl;
0273     return;
0274   }
0275   int totSize = 0;
0276   for (size_t i = 1; i < fetchTime.size(); i++) {
0277     totSize += fetchNum[i];
0278     auto delta = std::chrono::duration<double, std::milli>(fetchTime[i] - fetchTime[i - 1]).count();
0279     os << fetchNum[i] << " : " << delta << " ms (" << float(fetchNum[i]) / (1024. * float(delta)) << " MB/s)"
0280        << std::endl;
0281   }
0282   auto deltaAll = std::chrono::duration<double, std::milli>(fetchTime[fetchTime.size() - 1] - fetchTime[0]).count();
0283   os << "\noverall time for " << totSize << " bytes : " << deltaAll << " ms ("
0284      << float(totSize) / (1024. * float(deltaAll)) << " MB/s)" << std::endl;
0285   os << std::endl;
0286 }
0287 
0288 void Timer::showDeserInfo(std::ostream& os) {
0289   os << std::endl;
0290   os << "Serialization type: " << name << std::endl;
0291   if (deserTime.empty()) {
0292     os << "No deserialization info available." << std::endl;
0293     return;
0294   }
0295   int totSize = 0;
0296   for (size_t i = 1; i < deserTime.size(); i++) {
0297     totSize += deserNum[i];
0298     auto delta = std::chrono::duration<double, std::milli>(deserTime[i] - deserTime[i - 1]).count();
0299     os << deserNum[i] << " : " << delta << " ms (" << float(deserNum[i]) / (1024. * float(delta)) << " MB/s)"
0300        << std::endl;
0301   }
0302   auto deltaAll = std::chrono::duration<double, std::milli>(deserTime[deserTime.size() - 1] - deserTime[0]).count();
0303   os << "\noverall time for " << totSize << " bytes : " << deltaAll << " ms ("
0304      << float(totSize) / (1024. * float(deltaAll)) << " MB/s)" << std::endl;
0305   os << std::endl;
0306 }
0307 
0308 // ================================================================================
0309 
0310 cond::TestGTPerf::TestGTPerf() : Utilities("conddb_test_gt_load") {
0311   addConnectOption("connect", "c", "database connection string(required)");
0312   addAuthenticationOptions();
0313   addOption<size_t>("iterations", "n", "number of iterations (default=10)");
0314   addOption<Time_t>("start_run", "R", "start for Run iterations (default=150005)");
0315   addOption<Time_t>("step_run", "r", "step for Run iterations (default=1000)");
0316   addOption<Time_t>("start_ts", "T", "start for TS iterations (default=5800013687234232320)");
0317   addOption<Time_t>("step_ts", "t", "step for TS iterations (default=10000000000000)");
0318   addOption<Time_t>("start_lumi", "L", "start for Lumi iterations (default=908900979179966)");
0319   addOption<Time_t>("step_lumi", "l", "step for Lumi iterations (default=10000000000)");
0320   addOption<std::string>("globaltag", "g", "global tag (required)");
0321   addOption<bool>("verbose", "v", "verbose print out (optional)");
0322   addOption<int>("n_fetch", "f", "number of threads to load payloads (default=1)");
0323   addOption<int>("n_deser", "d", "number of threads do deserialize payloads (default=1)");
0324 }
0325 
0326 // thread helpers
0327 
0328 // global counter for dummy thread measurements:
0329 std::atomic<int> fooGlobal = 0;
0330 
0331 class FetchWorker {
0332 private:
0333   cond::ConnectionPoolWrapper& connectionPool;
0334   std::string connectionString;
0335   cond::UntypedPayloadProxy* p;
0336   std::map<std::string, size_t>* requests;
0337   cond::Time_t runSel;
0338   cond::Time_t lumiSel;
0339   cond::Time_t tsSel;
0340 
0341   boost::mutex my_lock;
0342 
0343 public:
0344   FetchWorker(cond::ConnectionPoolWrapper& connPool,
0345               const std::string& connString,
0346               cond::UntypedPayloadProxy* pIn,
0347               std::map<std::string, size_t>* reqIn,
0348               const cond::Time_t& run,
0349               const cond::Time_t& lumi,
0350               const cond::Time_t& ts)
0351       : connectionPool(connPool),
0352         connectionString(connString),
0353         p(pIn),
0354         requests(reqIn),
0355         runSel(run),
0356         lumiSel(lumi),
0357         tsSel(ts) {}
0358 
0359   void run() { runReal(); }
0360 
0361   void runFake() { fooGlobal++; }
0362   void runReal() {
0363     bool debug = false;
0364     bool loaded = false;
0365     cond::time::TimeType ttype = p->timeType();
0366     auto r = requests->find(p->tag());
0367     cond::Session s;
0368     try {
0369       s = connectionPool.createSession(connectionString);
0370       p->init(s);
0371       p->reload();
0372       if (ttype == cond::runnumber) {
0373         p->get(runSel, debug);
0374         boost::mutex::scoped_lock slock(my_lock);
0375         r->second++;
0376       } else if (ttype == cond::lumiid) {
0377         p->get(lumiSel, debug);
0378         boost::mutex::scoped_lock slock(my_lock);
0379         r->second++;
0380       } else if (ttype == cond::timestamp) {
0381         p->get(tsSel, debug);
0382         boost::mutex my_lock;
0383         r->second++;
0384       } else {
0385         std::cout << "WARNING: iov request on tag " << p->tag()
0386                   << " (timeType=" << cond::time::timeTypeName(p->timeType()) << ") has been skipped." << std::endl;
0387       }
0388       s.close();
0389       //-ap:  not thread-safe!  timex.fetchInt(p->getBufferSize()); // keep track of time vs. size
0390     } catch (const cond::Exception& e) {
0391       std::cout << "ERROR:" << e.what() << std::endl;
0392     }
0393   }
0394 };
0395 
0396 class DeserialWorker {
0397 private:
0398   cond::UntypedPayloadProxy* p;
0399   std::shared_ptr<void> payload;
0400   boost::mutex my_lock;
0401 
0402 public:
0403   DeserialWorker(cond::UntypedPayloadProxy* pIn, std::shared_ptr<void>& plIn) : p(pIn), payload(plIn) {}
0404 
0405   void run() { runReal(); }
0406 
0407   void runFake() { fooGlobal++; }
0408   void runReal() {
0409     std::shared_ptr<void> payloadPtr;
0410     std::string payloadTypeName = p->payloadType();
0411     const cond::Binary& buffer = p->getBuffer();
0412     const cond::Binary& streamerInfo = p->getStreamerInfo();
0413 
0414     auto result = std::make_unique<std::pair<std::string, std::shared_ptr<void> > >(
0415         cond::persistency::fetchOne(payloadTypeName, buffer, streamerInfo, payloadPtr));
0416     payload = result->second;
0417 
0418     return;
0419   }
0420 };
0421 
0422 template <typename T>
0423 struct invoker {
0424   void operator()(T& it) const { it->run(); }
0425 };
0426 
0427 int cond::TestGTPerf::execute() {
0428   std::string gtag = getOptionValue<std::string>("globaltag");
0429   bool debug = hasDebug();
0430   std::string connect = getOptionValue<std::string>("connect");
0431   bool verbose = hasOptionValue("verbose");
0432 
0433   int nThrF = getOptionValue<int>("n_fetch");
0434   int nThrD = getOptionValue<int>("n_deser");
0435   std::cout << "\n++> going to use " << nThrF << " threads for loading, " << nThrD << " threads for deserialization. \n"
0436             << std::endl;
0437 
0438   std::string serType = "unknown";
0439   if (connect.find("CMS_CONDITIONS") != -1) {
0440     serType = "ROOT-5";
0441   } else if (connect.find("CMS_TEST_CONDITIONS") != -1) {
0442     serType = "boost";
0443   }
0444 
0445   Time_t startRun = 150005;
0446   if (hasOptionValue("start_run"))
0447     startRun = getOptionValue<Time_t>("start_run");
0448   Time_t startTs = 5800013687234232320;
0449   if (hasOptionValue("start_ts"))
0450     startTs = getOptionValue<Time_t>("start_ts");
0451   Time_t startLumi = 908900979179966;
0452   if (hasOptionValue("start_lumi"))
0453     startLumi = getOptionValue<Time_t>("start_lumi");
0454 
0455   std::string authPath("");
0456   if (hasOptionValue("authPath"))
0457     authPath = getOptionValue<std::string>("authPath");
0458 
0459   initializePluginManager();
0460 
0461   Timer timex(serType);
0462 
0463   ConnectionPoolWrapper connPool(1, authPath, hasDebug());
0464   Session session = connPool.createSession(connect);
0465   session.transaction().start();
0466 
0467   std::cout << "Loading Global Tag " << gtag << std::endl;
0468   GTProxy gt = session.readGlobalTag(gtag);
0469 
0470   session.transaction().commit();
0471 
0472   std::cout << "Loading " << gt.size() << " tags..." << std::endl;
0473   std::vector<UntypedPayloadProxy*> proxies;
0474   std::map<std::string, size_t> requests;
0475   for (const auto& t : gt) {
0476     UntypedPayloadProxy* p = new UntypedPayloadProxy;
0477     p->init(session);
0478     try {
0479       p->load(t.tagName());
0480       if (nThrF == 1) {  // detailed info only needed in single-threaded mode to get the types/names
0481         p->setRecordInfo(t.recordName(), t.recordLabel());
0482       }
0483       proxies.push_back(p);
0484       requests.insert(std::make_pair(t.tagName(), 0));
0485     } catch (const cond::Exception& e) {
0486       std::cout << "ERROR: " << e.what() << std::endl;
0487     }
0488   }
0489   std::cout << proxies.size() << " tags successfully loaded." << std::endl;
0490   timex.interval("loading iovs");
0491 
0492   Time_t run = startRun;
0493   Time_t lumi = startLumi;
0494   Time_t ts = startTs;
0495 
0496   if (nThrF > 1)
0497     session.transaction().commit();
0498 
0499   tbb::global_control init(tbb::global_control::max_allowed_parallelism, nThrF);
0500   std::vector<std::shared_ptr<FetchWorker> > tasks;
0501 
0502   std::string payloadTypeName;
0503   for (auto p : proxies) {
0504     payloadTypeName = p->payloadType();
0505     // ignore problematic ones for now
0506     if ((payloadTypeName == "SiPixelGainCalibrationOffline")  // 2 * 133 MB !!!
0507     ) {
0508       std::cout << "WARNING: Ignoring problematic payload of type " << payloadTypeName << std::endl;
0509       continue;
0510     }
0511 
0512     if (nThrF > 1) {
0513       auto fw =
0514           std::make_shared<FetchWorker>(connPool, connect, p, (std::map<std::string, size_t>*)&requests, run, lumi, ts);
0515       tasks.push_back(fw);
0516     } else {
0517       bool loaded = false;
0518       time::TimeType ttype = p->timeType();
0519       auto r = requests.find(p->tag());
0520       try {
0521         if (ttype == runnumber) {
0522           p->get(run, hasDebug());
0523           r->second++;
0524         } else if (ttype == lumiid) {
0525           p->get(lumi, hasDebug());
0526           r->second++;
0527         } else if (ttype == timestamp) {
0528           p->get(ts, hasDebug());
0529           r->second++;
0530         } else {
0531           std::cout << "WARNING: iov request on tag " << p->tag() << " (timeType=" << time::timeTypeName(p->timeType())
0532                     << ") has been skipped." << std::endl;
0533         }
0534         timex.fetchInt(p->getBufferSize());  // keep track of time vs. size
0535       } catch (const cond::Exception& e) {
0536         std::cout << "ERROR:" << e.what() << std::endl;
0537       }
0538     }  // end else (single thread)
0539   }
0540 
0541   tbb::parallel_for_each(tasks.begin(), tasks.end(), invoker<std::shared_ptr<FetchWorker> >());
0542 
0543   std::cout << "global counter : " << fooGlobal << std::endl;
0544 
0545   if (nThrF == 1)
0546     session.transaction().commit();
0547   // session.transaction().commit();
0548 
0549   timex.interval("loading payloads");
0550 
0551   size_t totBufSize = 0;
0552   for (auto p : proxies) {
0553     totBufSize += p->getBufferSize();
0554   }
0555   std::cout << "++> total buffer size used : " << totBufSize << std::endl;
0556 
0557   std::vector<std::shared_ptr<void> > payloads;
0558   payloads.resize(400);  //-todo: check we don't have more payloads than that !!
0559 
0560   std::shared_ptr<void> payloadPtr;
0561 
0562   tbb::global_control initD(tbb::global_control::max_allowed_parallelism, nThrD);
0563   std::vector<std::shared_ptr<DeserialWorker> > tasksD;
0564 
0565   timex.interval("setup deserialization");
0566 
0567   int nEmpty = 0;
0568   int nBig = 0;
0569   int index = 0;
0570   for (auto p : proxies) {
0571     ///     if ( p->getBufferSize() == 0 ) { // nothing to do for these ...
0572     ///       std::cout << "empty buffer found for " << p->payloadType() << std::endl;
0573     ///       nEmpty++;
0574     ///       continue;
0575     ///     }
0576 
0577     payloadTypeName = p->payloadType();
0578 
0579     // ignore problematic ones for now
0580     if ((payloadTypeName == "SiPixelGainCalibrationForHLT") or
0581         (payloadTypeName == "SiPixelGainCalibrationOffline")  // 2 * 133 MB !!!
0582         or (payloadTypeName == "DTKeyedConfig") or (payloadTypeName == "std::vector<unsigned long long>") or
0583         (payloadTypeName == "  AlignmentSurfaceDeformations")
0584         // only in root for now:
0585         or (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer") or
0586         (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer") or
0587         (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer") or
0588         (payloadTypeName == "PhysicsTools::Calibration::MVAComputerContainer")) {
0589       std::cout << "INFO: Ignoring payload of type " << payloadTypeName << std::endl;
0590       continue;
0591     }
0592 
0593     if (nThrD > 1) {
0594       auto dw = std::make_shared<DeserialWorker>(p, payloads[index]);
0595       tasksD.push_back(dw);
0596     } else {  // single tread only
0597       try {
0598         std::pair<std::string, std::shared_ptr<void> > result =
0599             fetchOne(payloadTypeName, p->getBuffer(), p->getStreamerInfo(), payloadPtr);
0600         payloads.push_back(result.second);
0601       } catch (const cond::Exception& e) {
0602         std::cout << "\nERROR (cond): " << e.what() << std::endl;
0603         std::cout << "for payload type name: " << payloadTypeName << std::endl;
0604       } catch (const std::exception& e) {
0605         std::cout << "\nERROR (boost/std): " << e.what() << std::endl;
0606         std::cout << "for payload type name: " << payloadTypeName << std::endl;
0607       }
0608       timex.deserInt(p->getBufferSize());  // keep track of time vs. size
0609     }                                      // single-thread
0610     index++;                               // increment index into payloads
0611   }
0612   std::cout << std::endl;
0613 
0614   tbb::parallel_for_each(tasksD.begin(), tasksD.end(), invoker<std::shared_ptr<DeserialWorker> >());
0615 
0616   timex.interval("deserializing payloads");
0617 
0618   std::cout << "global counter : " << fooGlobal << std::endl;
0619   std::cout << "found   " << nEmpty << " empty payloads while deserialising " << std::endl;
0620 
0621   std::cout << std::endl;
0622   std::cout << "*** End of job." << std::endl;
0623   std::cout << "*** GT: " << gtag << " Tags:" << gt.size() << " Loaded:" << proxies.size() << std::endl;
0624   std::cout << std::endl;
0625   for (auto p : proxies) {
0626     auto r = requests.find(p->tag());
0627     if (verbose) {
0628       std::cout << "*** Tag: " << p->tag() << " Requests processed:" << r->second << " Queries:" << p->numberOfQueries()
0629                 << std::endl;
0630       const std::vector<std::string>& hist = p->history();
0631       for (const auto& e : p->history())
0632         std::cout << "    " << e << std::endl;
0633     }
0634   }
0635 
0636   // only for igprof checking of live mem:
0637   // ::exit(0);
0638 
0639   timex.interval("postprocessing ... ");
0640   timex.showIntervals();
0641 
0642   if (nThrF == 1) {
0643     std::ofstream ofs("fetchInfo.txt");
0644     timex.showFetchInfo(ofs);
0645     std::ofstream ofs2("sizeInfo.txt");
0646     for (auto p : proxies) {
0647       ofs2 << p->payloadType() << "[" << p->recName() << ":" << p->recLabel() << "]"
0648            << " : " << p->getBufferSize() << std::endl;
0649     }
0650   }
0651   if (nThrD == 1) {
0652     std::ofstream ofs1("deserializeInfo.txt");
0653     timex.showDeserInfo(ofs1);
0654   }
0655 
0656   return 0;
0657 }
0658 
0659 // ================================================================================
0660 
0661 int main(int argc, char** argv) {
0662   // usage: conddb_test_gt_perf -g START70_V1 -n 1 -c oracle://cms_orcoff_prep/CMS_CONDITIONS --n_fetch 1 --n_deser 1 2>&1 | tee run.log
0663   // usage: conddb_test_gt_perf -g START70_V1 -n 1 -c oracle://cms_orcoff_prep/CMS_TEST_CONDITIONS --n_fetch 2 --n_deser 8 2>&1 | tee run_2f_8d.log
0664 
0665   cond::TestGTPerf test;
0666   return test.run(argc, argv);
0667 }