Skip to content

Commit 768f803

Browse files
committed
Optional detailed report on BasicCCDBManager cache
1 parent 7f58571 commit 768f803

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class CCDBManagerInstance
4848
std::string uuid;
4949
long startvalidity = 0;
5050
long endvalidity = -1;
51+
size_t minSize = -1ULL;
52+
size_t maxSize = 0;
5153
int queries = 0;
5254
int fetches = 0;
5355
int failures = 0;
@@ -176,7 +178,7 @@ class CCDBManagerInstance
176178

177179
std::string getSummaryString() const;
178180

179-
void endOfStream();
181+
void report(bool longrep = false);
180182

181183
private:
182184
// method to print (fatal) error
@@ -221,8 +223,8 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
221223
}
222224
} else {
223225
auto& cached = mCache[path];
226+
cached.queries++;
224227
if (mCheckObjValidityEnabled && cached.isValid(timestamp)) {
225-
cached.queries++;
226228
return reinterpret_cast<T*>(cached.noCleanupPtr ? cached.noCleanupPtr : cached.objPtr.get());
227229
}
228230
ptr = mCCDBAccessor.retrieveFromTFileAny<T>(path, mMetaData, timestamp, &mHeaders, cached.uuid,
@@ -244,6 +246,12 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
244246
} catch (std::exception const& e) {
245247
reportFatal("Failed to read validity from CCDB response (Valid-From : " + mHeaders["Valid-From"] + std::string(" Valid-Until: ") + mHeaders["Valid-Until"] + std::string(")"));
246248
}
249+
auto sh = mHeaders.find("fileSize");
250+
if (sh != mHeaders.end()) {
251+
size_t s = atol(sh->second.c_str());
252+
cached.minSize = std::min(s, cached.minSize);
253+
cached.maxSize = std::max(s, cached.minSize);
254+
}
247255
} else if (mHeaders.count("Error")) { // in case of errors the pointer is 0 and headers["Error"] should be set
248256
cached.failures++;
249257
cached.clear(); // in case of any error clear cache for this object

CCDB/src/BasicCCDBManager.cxx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ std::string CCDBManagerInstance::getSummaryString() const
7272
return res;
7373
}
7474

75-
void CCDBManagerInstance::endOfStream()
75+
void CCDBManagerInstance::report(bool longrep)
7676
{
7777
LOG(info) << "CCDBManager summary: " << getSummaryString();
78+
if (longrep && mCachingEnabled) {
79+
LOGP(info, "CCDB cache miss/hit/failures");
80+
for (const auto& obj : mCache) {
81+
LOGP(info, " {}: {}/{}/{} ({}-{} bytes)", obj.first, obj.second.fetches, obj.second.queries - obj.second.fetches - obj.second.failures, obj.second.failures, obj.second.minSize, obj.second.maxSize);
82+
}
83+
}
7884
}
7985

8086
} // namespace ccdb

0 commit comments

Comments
 (0)