@@ -55,6 +55,7 @@ class CCDBManagerInstance
5555 long endvalidity = -1 ;
5656 long cacheValidFrom = 0 ; // time for which the object was cached
5757 long cacheValidUntil = -1 ; // object is guaranteed to be valid till this time (modulo new updates)
58+ size_t size = 0 ;
5859 size_t minSize = -1ULL ;
5960 size_t maxSize = 0 ;
6061 int queries = 0 ;
@@ -229,6 +230,7 @@ class CCDBManagerInstance
229230 long mCreatedNotBefore = 0 ; // lower limit for object creation timestamp (TimeMachine mode) - If-Not-Before HTTP header
230231 long mTimerMS = 0 ; // timer for queries
231232 size_t mFetchedSize = 0 ; // total fetched size
233+ size_t mRequestedSize = 0 ; // total requested size (fetched + served from cache)
232234 int mQueries = 0 ; // total number of object queries
233235 int mFetches = 0 ; // total number of succesful fetches from CCDB
234236 int mFailures = 0 ; // total number of failed fetches
@@ -258,6 +260,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
258260 if (sh != mHeaders .end ()) {
259261 size_t s = atol (sh->second .c_str ());
260262 mFetchedSize += s;
263+ mRequestedSize += s;
261264 }
262265 }
263266
@@ -272,6 +275,7 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
272275 if (headers) {
273276 *headers = cached.cacheOfHeaders ;
274277 }
278+ mRequestedSize += cached.size ;
275279 return reinterpret_cast <T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr .get ());
276280 }
277281 ptr = mCCDBAccessor .retrieveFromTFileAny <T>(path, mMetaData , timestamp, &mHeaders , cached.uuid ,
@@ -318,6 +322,8 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
318322 if (sh != mHeaders .end ()) {
319323 size_t s = atol (sh->second .c_str ());
320324 mFetchedSize += s;
325+ mRequestedSize += s;
326+ cached.size = s;
321327 cached.minSize = std::min (s, cached.minSize );
322328 cached.maxSize = std::max (s, cached.minSize );
323329 }
@@ -342,12 +348,14 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
342348 }
343349 auto end = std::chrono::system_clock::now ();
344350 mTimerMS += std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count ();
345- auto * ref = o2::framework::ServiceRegistryRef::globalDeviceRef ();
351+ auto * ref = o2::framework::ServiceRegistryRef::globalDeviceRef ();
346352 if (ref && ref->active <framework::DataProcessingStats>()) {
347353 auto & stats = ref->get <o2::framework::DataProcessingStats>();
348354 stats.updateStats ({(int )o2::framework::ProcessingStatsId::CCDB_CACHE_HIT, o2::framework::DataProcessingStats::Op::Set, (int64_t )mQueries - mFailures - mFetches });
349355 stats.updateStats ({(int )o2::framework::ProcessingStatsId::CCDB_CACHE_MISS, o2::framework::DataProcessingStats::Op::Set, (int64_t )mFetches });
350356 stats.updateStats ({(int )o2::framework::ProcessingStatsId::CCDB_CACHE_FAILURE, o2::framework::DataProcessingStats::Op::Set, (int64_t )mFailures });
357+ stats.updateStats ({(int )o2::framework::ProcessingStatsId::CCDB_CACHE_FETCHED_BYTES, o2::framework::DataProcessingStats::Op::Set, (int64_t )mFetchedSize });
358+ stats.updateStats ({(int )o2::framework::ProcessingStatsId::CCDB_CACHE_REQUESTED_BYTES, o2::framework::DataProcessingStats::Op::Set, (int64_t )mRequestedSize });
351359 }
352360 return ptr;
353361}
0 commit comments