Skip to content

Commit ed7ff4f

Browse files
authored
Merge pull request #289 from sy-c/master
v2.27.2
2 parents bc621c5 + b206dd3 commit ed7ff4f

14 files changed

+123
-10
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ add_library(
258258
${SOURCE_DIR}/MemoryBank.cxx
259259
${SOURCE_DIR}/MemoryBankManager.cxx
260260
${SOURCE_DIR}/MemoryPagesPool.cxx
261+
${SOURCE_DIR}/ReadoutMonitoringQueue.cxx
261262
$<$<BOOL:${ZMQ_FOUND}>:${SOURCE_DIR}/ZmqServer.cxx>
262263
$<$<BOOL:${ZMQ_FOUND}>:${SOURCE_DIR}/ZmqClient.cxx>
263264
)

doc/configurationParameters.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ The parameters related to 3rd-party libraries are described here for convenience
161161
| equipment-* | saveErrorPagesMax | int | 0 | If set, pages found with data error are saved to disk up to given maximum. |
162162
| equipment-* | saveErrorPagesPath | string | | Path where to save data pages with errors (when feature enabled). |
163163
| equipment-* | stopOnError | int | 0 | If 1, readout will stop automatically on equipment error. |
164-
| equipment-* | TFperiod | int | 128 | Duration of a timeframe, in number of LHC orbits. |
164+
| equipment-* | TFperiod | int | 32 | Duration of a timeframe, in number of LHC orbits. |
165165
| equipment-* | verbose | int | 0 | If set, extra debug messages may be logged. |
166166
| equipment-cruemulator-* | cruBlockSize | int | 8192 | Size of a RDH block. |
167167
| equipment-cruemulator-* | cruId | int | 0 | CRU Id, used for CRU Id field in RDH. |
@@ -194,6 +194,7 @@ The parameters related to 3rd-party libraries are described here for convenience
194194
| equipment-rorc-* | firmwareCheckEnabled | int | 1 | If set, RORC driver checks compatibility with detected firmware. Use 0 to bypass this check (eg new fw version not yet recognized by ReadoutCard version). |
195195
| equipment-rorc-* | firmwareVersionsAllowed | string | | Comma-separated list of ROC firmware versions allowed (6-digit hash). If empty, all are allowed. |
196196
| equipment-rorc-* | firmwareVersionsDenied | string | e4a5a46e | Comma-separated list of ROC firmware versions denied (6-digit hash), i.e. which would cause configuration to abort. |
197+
| equipment-rorc-* | monitorFirstOrbitEnabled | int | 0 | If set, enable monitoring of RORC first orbit. |
197198
| equipment-zmq-* | address | string | | Address of remote server to connect, eg tcp://remoteHost:12345. |
198199
| equipment-zmq-* | mode | string | stream | Possible values: stream (1 input ZMQ message = 1 output data page), snapshot (last ZMQ message = one output data page per TF). |
199200
| equipment-zmq-* | timeframeClientUrl | string | | The address to be used to retrieve current timeframe. When set, data is published only once for each TF id published by remote server. |

doc/releaseNotes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,3 +655,9 @@ This file describes the main feature changes for each readout.exe released versi
655655

656656
## v2.27.1 - 12/02/2025
657657
- Path of configuration file from which defaults are loaded on startup has been changed to /etc/o2.d/readout/readout-defaults.cfg (it was in /etc/o2.d before, now changing to standard subdirectory location).
658+
659+
## v2.27.2 - 19/03/2025
660+
- Updated configuration parameters:
661+
- equipment.TFperiod is now set to 32 by default, instead of 128 previously. This is the duration of a timeframe, in number of LHC orbits. The new value corresponds to what is used in production.
662+
- equipment-rorc-*: added parameter monitorFirstOrbitEnabled, to enable reporting to monitoring system the metric "readout.RORCfirstOrbit" on startup, as retrieved from CRU firmware. This is to be used on CTP FLP to detect possibly wrong orbit. A return value of 0xFFFFFFFF indicates the value could not be retrieved.
663+
- ConsumerStats: added an internal queue to allow pushing spontaneous monitoring measurements (compared to periodic ones) from any readout module.

src/ConsumerStats.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "DataSet.h"
2424
#include "ReadoutUtils.h"
2525
#include "ReadoutStats.h"
26+
#include "ReadoutMonitoringQueue.h"
2627

2728
using namespace o2::monitoring;
2829

@@ -182,6 +183,12 @@ class ConsumerStats : public Consumer
182183
sendMetricNoException(Metric{"readout.bufferUsage"}.addValue((int)(r*100), "value").addValue(b, "bytes").addTag(tags::Key::ID, i));
183184
}
184185
}
186+
187+
// publish measurements stored in monitoring queue
188+
auto ff = [&] (const ReadoutMonitoringMetric &m) -> void {
189+
sendMetricNoException(Metric{m.value, m.name}.addTag(tags::Key::ID, m.tag));
190+
};
191+
gReadoutMonitoringQueue.execute(ff);
185192
}
186193

187194
#ifdef WITH_ZMQ

src/ReadoutEquipment.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ ReadoutEquipment::ReadoutEquipment(ConfigFile& cfg, std::string cfgEntryPoint, b
161161
cfg.getOptionalValue<int>(cfgEntryPoint + ".verbose", cfgVerbose);
162162

163163
if (!cfgDisableTimeframes) {
164-
// configuration parameter: | equipment-* | TFperiod | int | 128 | Duration of a timeframe, in number of LHC orbits. |
165-
int cfgTFperiod = 128;
164+
// configuration parameter: | equipment-* | TFperiod | int | 32 | Duration of a timeframe, in number of LHC orbits. |
165+
int cfgTFperiod = 32;
166166
cfg.getOptionalValue<int>(cfgEntryPoint + ".TFperiod", cfgTFperiod);
167167
timeframePeriodOrbits = cfgTFperiod;
168168

src/ReadoutEquipment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class ReadoutEquipment
165165

166166
//const unsigned int LHCBunches = 3564; // number of bunches in LHC
167167
const unsigned int LHCOrbitRate = 11246; // LHC orbit rate, in Hz. 299792458 / 26659
168-
uint32_t timeframePeriodOrbits = 128; // timeframe interval duration in number of LHC orbits
168+
uint32_t timeframePeriodOrbits = 32; // timeframe interval duration in number of LHC orbits
169169
double timeframeRate = 0; // timeframe rate, when generated internally
170170

171171
// RDH-related configuration parameters

src/ReadoutEquipmentRORC.cxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ReadoutEquipment.h"
2727
#include "ReadoutUtils.h"
2828
#include "readoutInfoLogger.h"
29+
#include "ReadoutMonitoringQueue.h"
2930

3031
class ReadoutEquipmentRORC : public ReadoutEquipment
3132
{
@@ -131,6 +132,10 @@ ReadoutEquipmentRORC::ReadoutEquipmentRORC(ConfigFile& cfg, std::string name) :
131132
// configuration parameter: | equipment-rorc-* | debugStatsEnabled | int | 0 | If set, enable extra statistics about internal buffers status. (printed to stdout when stopping) |
132133
cfg.getOptionalValue<int>(name + ".debugStatsEnabled", cfgDebugStatsEnabled);
133134

135+
// configuration parameter: | equipment-rorc-* | monitorFirstOrbitEnabled | int | 0 | If set, enable monitoring of RORC first orbit. |
136+
int cfgMonitorFirstOrbitEnabled = 0;
137+
cfg.getOptionalValue<int>(name + ".monitorFirstOrbitEnabled", cfgMonitorFirstOrbitEnabled);
138+
134139
// get readout memory buffer parameters
135140
// std::string sMemorySize=cfg.getValue<std::string>(name + ".memoryBufferSize");
136141
// std::string sPageSize=cfg.getValue<std::string>(name + ".memoryPageSize"); long long
@@ -216,6 +221,11 @@ ReadoutEquipmentRORC::ReadoutEquipmentRORC(ConfigFile& cfg, std::string name) :
216221
BOOST_THROW_EXCEPTION(ReadoutEquipmentRORCException() << ErrorInfo::Message("This firmware version is not allowed"));
217222
}
218223

224+
// publish relevant card info
225+
if (cfgMonitorFirstOrbitEnabled) {
226+
gReadoutMonitoringQueue.push({.name = "readout.RORCfirstOrbit", .tag = id, .value = (uint64_t)channel->getCounterFirstOrbit()});
227+
}
228+
219229
// todo: log parameters ?
220230

221231
if (logRocCallsEnable) {

src/ReadoutMonitoringQueue.cxx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "ReadoutMonitoringQueue.h"
2+
3+
ReadoutMonitoringQueue::ReadoutMonitoringQueue() {
4+
}
5+
6+
ReadoutMonitoringQueue::~ReadoutMonitoringQueue() {
7+
}
8+
9+
void ReadoutMonitoringQueue::push(ReadoutMonitoringMetric m) {
10+
std::unique_lock<std::mutex> lock(qMutex);
11+
q.push_front(std::move(m));
12+
}
13+
14+
void ReadoutMonitoringQueue::execute(std::function<void(const ReadoutMonitoringMetric &)> f) {
15+
for (;;) {
16+
ReadoutMonitoringMetric m;
17+
18+
{
19+
std::unique_lock<std::mutex> lock(qMutex);
20+
if (q.empty()) {
21+
break;
22+
}
23+
m = std::move(q.back());
24+
q.pop_back();
25+
}
26+
27+
f(m);
28+
}
29+
}
30+
31+
void ReadoutMonitoringQueue::clear() {
32+
std::unique_lock<std::mutex> lock(qMutex);
33+
q.clear();
34+
}
35+
36+
ReadoutMonitoringQueue gReadoutMonitoringQueue;

src/ReadoutMonitoringQueue.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <deque>
2+
#include <mutex>
3+
#include <string>
4+
#include <functional>
5+
6+
// a metric to be stored in queue for later processing
7+
// fields as for o2::monitoring::metric
8+
struct ReadoutMonitoringMetric {
9+
std::string name;
10+
unsigned short int tag;
11+
uint64_t value;
12+
};
13+
14+
15+
// producer-consumer queue to define and publish metrics
16+
// typical use:
17+
// the module that pushes has no access to o2 Monitoring
18+
// the module that publishes reads from the queue and publish them to o2 Monitoring
19+
// the class is not aware of o2::monitoring, it's just a transient thread-safe storage
20+
21+
class ReadoutMonitoringQueue {
22+
public:
23+
24+
ReadoutMonitoringQueue();
25+
~ReadoutMonitoringQueue();
26+
27+
// push an element in the queue
28+
void push(ReadoutMonitoringMetric);
29+
30+
// execute provided functions on all elements in the queue
31+
// (and remove them from the queue)
32+
void execute(std::function<void(const ReadoutMonitoringMetric &)>);
33+
34+
// remove all elements in queue
35+
void clear();
36+
37+
private:
38+
std::mutex qMutex;
39+
std::deque<ReadoutMonitoringMetric> q;
40+
};
41+
42+
extern ReadoutMonitoringQueue gReadoutMonitoringQueue;

src/ReadoutVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#define READOUT_VERSION "2.27.1"
12+
#define READOUT_VERSION "2.27.2"
1313

0 commit comments

Comments
 (0)