Project
Loading...
Searching...
No Matches
CallbacksPolicy.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
16#include "Framework/Logger.h"
20#include <cstdlib>
21#include <uv.h>
22
23namespace o2::framework
24{
25
26static bool checkPrescale(const TimingInfo& info, int prescale, bool startProcessing)
27{
28 if (prescale <= 1) {
29 static size_t counter = 0;
30 static size_t downscaleFactor = 1;
31 if (startProcessing) {
32 counter++;
33 }
34 if (counter <= 100000) {
35 return true;
36 }
37 if (counter > 100000 * downscaleFactor) {
38 downscaleFactor *= 10;
39 LOG(info) << "Processed " << counter << " timeslices / timers, increasing reporting downscale factor to " << downscaleFactor;
40 }
41 return counter % downscaleFactor == 0;
42 }
43 return info.isTimer() || !(info.timeslice % prescale);
44}
45
47{
48 int prescale = 1;
49 bool forceReport = false;
50 if (getenv("DPL_REPORT_PROCESSING") != nullptr && (prescale = std::abs(atoi(getenv("DPL_REPORT_PROCESSING"))))) {
51 forceReport = true;
52 }
53 if (!prescale) {
54 prescale = 1;
55 }
56 return {
57 .matcher = [forceReport](DeviceSpec const&, ConfigContext const& context) -> bool {
59 return report;
60 },
61 .policy = [prescale](CallbackService& callbacks, InitContext& context) -> void {
62 callbacks.set<CallbackService::Id::PreProcessing>([prescale](ServiceRegistryRef registry, int op) {
63 auto& info = registry.get<TimingInfo>();
64 if ((int)info.firstTForbit != -1 && checkPrescale(info, prescale, true)) {
65 char const* what = info.isTimer() ? "timer" : "timeslice";
66 LOGP(info, "Processing {}:{}, tfCounter:{}, firstTForbit:{}, runNumber:{}, creation:{}, action:{}",
67 what, info.timeslice, info.tfCounter, info.firstTForbit, info.runNumber, info.creation, op);
68 }
69 info.lapse = uv_hrtime();
70 });
71 callbacks.set<CallbackService::Id::PostProcessing>([prescale](ServiceRegistryRef registry, int op) {
72 auto& info = registry.get<TimingInfo>();
73 if ((int)info.firstTForbit != -1 && checkPrescale(info, prescale, false)) {
74 char const* what = info.isTimer() ? "timer" : "timeslice";
75 LOGP(info, "Done processing {}:{}, tfCounter:{}, firstTForbit:{}, runNumber:{}, creation:{}, action:{}, wall:{}",
76 what, info.timeslice, info.tfCounter, info.firstTForbit, info.runNumber, info.creation, op, uv_hrtime() - info.lapse);
77 }
78 });
79 }};
80}
81
82std::vector<CallbacksPolicy> CallbacksPolicy::createDefaultPolicies()
83{
84 return {
86}
87
88} // namespace o2::framework
uint32_t op
@ PreProcessing
Invoked before the processing callback.
@ PostProcessing
Invoked after the processing callback,.
GLuint counter
Definition glcorearb.h:3987
void report(gsl::span< o2::InteractionTimeRecord > irs, int threshold, bool verbose)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
CallbacksPolicy epnProcessReporting()
static std::vector< CallbacksPolicy > createDefaultPolicies()
static DeploymentMode deploymentMode()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"