@@ -96,6 +96,11 @@ void StfBuilderDevice::InitTask()
9696 I ().mMaxStfsInPipeline = GetConfig ()->GetValue <std::int64_t >(OptionKeyMaxBufferedStfs);
9797 I ().mMaxBuiltStfs = GetConfig ()->GetValue <std::uint64_t >(OptionKeyMaxBuiltStfs);
9898
99+ // start monitoring
100+ DataDistMonitor::start_datadist (o2::monitoring::tags::Value::StfBuilder, GetConfig ()->GetProperty <std::string>(" monitoring-backend" , " " ));
101+ DataDistMonitor::set_rate (GetConfig ()->GetValue <float >(" monitoring-rate" ));
102+ DataDistMonitor::set_log (GetConfig ()->GetValue <bool >(" monitoring-log" ));
103+
99104 // input data handling
100105 ReadoutDataUtils::sSpecifiedDataOrigin = getDataOriginFromOption (
101106 GetConfig ()->GetValue <std::string>(OptionKeyStfDetector));
@@ -222,9 +227,6 @@ void StfBuilderDevice::InitTask()
222227 I ().mReadoutInterface ->start ();
223228 }
224229
225- // info thread
226- I ().mInfoThread = create_thread_member (" stfb_info" , &StfBuilderDevice::InfoThread, this );
227-
228230 IDDLOG (" InitTask() done... " );
229231}
230232
@@ -257,11 +259,6 @@ void StfBuilderDevice::ResetTask()
257259 I ().mOutputThread .join ();
258260 }
259261
260- // wait for the info thread
261- if (I ().mInfoThread .joinable ()) {
262- I ().mInfoThread .join ();
263- }
264-
265262 // stop the memory resources very last
266263 MemI ().stop ();
267264
@@ -270,6 +267,8 @@ void StfBuilderDevice::ResetTask()
270267
271268void StfBuilderDevice::StfOutputThread ()
272269{
270+ using hres_clock = std::chrono::high_resolution_clock;
271+
273272 std::unique_ptr<InterleavedHdrDataSerializer> lStfSerializer;
274273 std::unique_ptr<StfToDplAdapter> lStfDplAdapter;
275274
@@ -285,27 +284,35 @@ void StfBuilderDevice::StfOutputThread()
285284 }
286285 }
287286
288- while (I ().mState .mRunning ) {
289- using hres_clock = std::chrono::high_resolution_clock;
287+ decltype (hres_clock::now ()) lStfStartTime = hres_clock::now ();
290288
289+ while (I ().mState .mRunning ) {
291290 // Get a STF ready for sending
292291 std::unique_ptr<SubTimeFrame> lStf = I ().dequeue (eStfSendIn);
293292 if (!lStf) {
293+ DDMON (" stfbuilder" , " stf_input.rate" , 0 );
294+ DDMON (" stfbuilder" , " stf_input.size" , 0 );
294295 break ;
295296 }
296297
297298 // decrement the stf counter
298299 I ().mCounters .mNumStfs --;
299300
300- DDDLOG_RL (2000 , " Sending an STF out. stf_id={} stf_size={} unique_equipments={}" ,
301- lStf->header (). mId , lStf->getDataSize (), lStf->getEquipmentIdentifiers ().size ());
301+ DDDLOG_RL (5000 , " Sending an STF out. stf_id={} stf_size={} unique_equipments={}" ,
302+ lStf->id () , lStf->getDataSize (), lStf->getEquipmentIdentifiers ().size ());
302303
303- // get data size sample
304- I ().mStfSizeMean += (lStf->getDataSize ()/64 - I ().mStfSizeMean /64 );
304+ {
305+ // Output STF frequency
306+ const auto lNow = hres_clock::now ();
307+ const auto lStfDur = std::chrono::duration<double >(lNow - lStfStartTime);
308+ lStfStartTime = lNow;
305309
306- if (!isStandalone ()) {
307- const auto lSendStartTime = hres_clock::now ();
310+ DDMON (" stfbuilder" , " stf_output.rate" , (1.0 / lStfDur.count ()));
311+ DDMON (" stfbuilder" , " stf_output.size" , lStf->getDataSize ());
312+ DDMON (" stfbuilder" , " stf_output.id" , lStf->id ());
313+ }
308314
315+ if (!isStandalone ()) {
309316 try {
310317
311318 if (!dplEnabled ()) {
@@ -335,11 +342,10 @@ void StfBuilderDevice::StfOutputThread()
335342
336343 I ().mSentOutStfs ++;
337344 I ().mSentOutStfsTotal ++;
345+ DDMON (" stfbuilder" , " stf_output.total" , I ().mSentOutStfsTotal );
338346
339347 const auto lNow = hres_clock::now ();
340- const double lTimeMs = std::max (1e-6 , std::chrono::duration<double , std::milli>(lNow - lSendStartTime).count ());
341348 I ().mSentOutRate = double (I ().mSentOutStfs ) / std::chrono::duration<double >(lNow - sStartOfStfSending ).count ();
342- I ().mStfDataTimeSamples += (lTimeMs / 100.0 - I ().mStfDataTimeSamples / 100.0 );
343349 }
344350
345351 // check if we should exit:
@@ -380,24 +386,7 @@ void StfBuilderDevice::StfOutputThread()
380386 DDDLOG (" Exiting StfOutputThread..." );
381387}
382388
383- void StfBuilderDevice::InfoThread ()
384- {
385- while (I ().mState .mRunning ) {
386-
387- std::this_thread::sleep_for (2s);
388-
389- if (I ().mState .mPaused ) {
390- continue ;
391- }
392389
393- IDDLOG (" SubTimeFrame size_mean={} frequency_mean={:.4} sending_time_ms_mean={:.4} queued_stf={}" ,
394- I ().mStfSizeMean , (1.0 / I ().mReadoutInterface ->StfTimeMean ()),
395- I ().mStfDataTimeSamples , I ().mCounters .mNumStfs );
396- IDDLOG (" SubTimeFrame sent_total={} rate={:.4}" , I ().mSentOutStfsTotal , I ().mSentOutRate );
397- }
398-
399- DDDLOG (" Exiting Info thread..." );
400- }
401390
402391bool StfBuilderDevice::ConditionalRun ()
403392{
0 commit comments