Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CCDB/include/CCDB/BasicCCDBManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "CommonUtils/NameConf.h"
#include "Framework/DataTakingContext.h"
#include "Framework/DefaultsHelpers.h"
#include "Framework/ServiceRegistryRef.h"
#include "Framework/DataProcessingStats.h"
#include <string>
#include <chrono>
#include <map>
Expand Down Expand Up @@ -340,6 +342,13 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp,
}
auto end = std::chrono::system_clock::now();
mTimerMS += std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
auto *ref = o2::framework::ServiceRegistryRef::globalDeviceRef();
if (ref && ref->active<framework::DataProcessingStats>()) {
auto& stats = ref->get<o2::framework::DataProcessingStats>();
stats.updateStats({(int)o2::framework::ProcessingStatsId::CCDB_CACHE_HIT, o2::framework::DataProcessingStats::Op::Set, (int64_t)mQueries - mFailures - mFetches});
stats.updateStats({(int)o2::framework::ProcessingStatsId::CCDB_CACHE_MISS, o2::framework::DataProcessingStats::Op::Set, (int64_t)mFetches});
stats.updateStats({(int)o2::framework::ProcessingStatsId::CCDB_CACHE_FAILURE, o2::framework::DataProcessingStats::Op::Set, (int64_t)mFailures});
}
return ptr;
}

Expand Down Expand Up @@ -391,4 +400,4 @@ class BasicCCDBManager : public CCDBManagerInstance

} // namespace o2::ccdb

#endif //O2_BASICCCDBMANAGER_H
#endif // O2_BASICCCDBMANAGER_H
2 changes: 2 additions & 0 deletions CCDB/src/BasicCCDBManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// Created by Sandro Wenzel on 2019-08-14.
//
#include "CCDB/BasicCCDBManager.h"
#include "Framework/ServiceRegistryRef.h"
#include "Framework/DataProcessingStats.h"
#include <boost/lexical_cast.hpp>
#include <fairlogger/Logger.h>
#include <string>
Expand Down
1 change: 1 addition & 0 deletions Framework/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ o2_add_library(Framework
src/RootArrowFilesystem.cxx
src/SendingPolicy.cxx
src/ServiceRegistry.cxx
src/ServiceRegistryRef.cxx
src/ServiceSpec.cxx
src/SimpleResourceManager.cxx
src/SimpleRawDeviceService.cxx
Expand Down
3 changes: 3 additions & 0 deletions Framework/Core/include/Framework/DataProcessingStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ enum struct ProcessingStatsId : short {
RESOURCES_MISSING,
RESOURCES_INSUFFICIENT,
RESOURCES_SATISFACTORY,
CCDB_CACHE_HIT,
CCDB_CACHE_MISS,
CCDB_CACHE_FAILURE,
AVAILABLE_MANAGED_SHM_BASE = 512,
};

Expand Down
2 changes: 2 additions & 0 deletions Framework/Core/include/Framework/ServiceRegistryRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class ServiceRegistryRef
mRegistry.unlock(mSalt);
}

static ServiceRegistryRef *globalDeviceRef(ServiceRegistryRef *ref = nullptr);

private:
ServiceRegistry& mRegistry;
ServiceRegistry::Salt mSalt;
Expand Down
24 changes: 24 additions & 0 deletions Framework/Core/src/CommonServices.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,30 @@ o2::framework::ServiceSpec CommonServices::dataProcessingStats()
.scope = Scope::DPL,
.minPublishInterval = 0,
.maxRefreshLatency = 10000,
.sendInitialValue = true},
MetricSpec{.name = "ccdb-cache-hit",
.enabled = true,
.metricId = static_cast<short>(ProcessingStatsId::CCDB_CACHE_HIT),
.kind = Kind::UInt64,
.scope = Scope::DPL,
.minPublishInterval = 1000,
.maxRefreshLatency = 10000,
.sendInitialValue = true},
MetricSpec{.name = "ccdb-cache-miss",
.enabled = true,
.metricId = static_cast<short>(ProcessingStatsId::CCDB_CACHE_MISS),
.kind = Kind::UInt64,
.scope = Scope::DPL,
.minPublishInterval = 1000,
.maxRefreshLatency = 10000,
.sendInitialValue = true},
MetricSpec{.name = "ccdb-cache-failure",
.enabled = true,
.metricId = static_cast<short>(ProcessingStatsId::CCDB_CACHE_FAILURE),
.kind = Kind::UInt64,
.scope = Scope::DPL,
.minPublishInterval = 1000,
.maxRefreshLatency = 10000,
.sendInitialValue = true}};

for (auto& metric : metrics) {
Expand Down
25 changes: 25 additions & 0 deletions Framework/Core/src/ServiceRegistryRef.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.


#include "Framework/ServiceRegistryRef.h"
namespace o2::framework {

ServiceRegistryRef *ServiceRegistryRef::globalDeviceRef(ServiceRegistryRef *ref) {
static ServiceRegistryRef *globalRef = nullptr;
if (!globalRef) {
globalRef = ref;
}
// We return a copy, so that it can be cache
return globalRef;
}

}
2 changes: 2 additions & 0 deletions Framework/Core/src/runDataProcessing.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,7 @@ std::vector<std::regex> getDumpableMetrics()
dumpableMetrics.emplace_back("^total-timeframes.*");
dumpableMetrics.emplace_back("^device_state.*");
dumpableMetrics.emplace_back("^total_wall_time_ms$");
dumpableMetrics.emplace_back("^ccdb-.*$");
return dumpableMetrics;
}

Expand Down Expand Up @@ -1429,6 +1430,7 @@ int runStateMachine(DataProcessorSpecs const& workflow,
// We initialise this in the driver, because different drivers might have
// different versions of the service
ServiceRegistry serviceRegistry;
ServiceRegistryRef::globalDeviceRef(new ServiceRegistryRef{serviceRegistry, ServiceRegistry::globalDeviceSalt()});

if ((driverConfig.batch == false || getenv("DPL_DRIVER_REMOTE_GUI") != nullptr) && frameworkId.empty()) {
debugGUI = initDebugGUI();
Expand Down
Loading