Skip to content

Commit 766b824

Browse files
committed
TF rate limit fix
1 parent cbc8415 commit 766b824

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

src/ReadoutEquipmentPlayer.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class ReadoutEquipmentPlayer : public ReadoutEquipment
5555

5656
uint32_t orbitOffset = 0; // to be applied to orbit after 1st loop
5757
int cfgUpdateOrbits = 1; // when set, all RDHs are modified to update orbit, according to orbitOffset
58-
58+
int cfgAutoTimeframeId = 0; // when set, TFids are generated incrementally instead of taken from RDH BC.
59+
5960
void copyFileDataToPage(void* page); // fill given page with file data according to current settings
6061
};
6162

@@ -102,6 +103,8 @@ ReadoutEquipmentPlayer::ReadoutEquipmentPlayer(ConfigFile& cfg, std::string cfgE
102103
cfg.getOptionalValue<int>(cfgEntryPoint + ".autoChunkLoop", autoChunkLoop, 0);
103104
// configuration parameter: | equipment-player-* | updateOrbits | int | 1 | When set, trigger orbit counters in all RDH are modified for iterations after the first one (in file loop replay mode), so that they keep increasing. |
104105
cfg.getOptionalValue<int>(cfgEntryPoint + ".updateOrbits", cfgUpdateOrbits, 1);
106+
// configuration parameter: | equipment-player-* | autoTimeframeId | int | 0 | When set, timeframe IDs are generated incrementally instead of being computed from trigger orbit counters. Useful to replay files with unordered / gap between TF. BC still used to detect boundaries between TFs. |
107+
cfg.getOptionalValue<int>(cfgEntryPoint + ".autoTimeframeId", cfgAutoTimeframeId, 0);
105108

106109
// log config summary
107110
theLog.log(LogInfoDevel_(3002), "Equipment %s: using data source file=%s preLoad=%d fillPage=%d autoChunk=%d autoChunkLoop=%d updateOrbits=%d", name.c_str(), filePath.c_str(), preLoad, fillPage, autoChunk, autoChunkLoop, cfgUpdateOrbits);

src/mainReadout.cxx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ class Readout
408408
void publishLogbookStats(); // publish current readout counters to logbook
409409
AliceO2::Common::Timer logbookTimer; // timer to handle readout logbook publish interval
410410

411-
uint64_t maxTimeframeId;
411+
uint64_t currentTimeframeId = undefinedTimeframeId;
412412
uint64_t countTimeframeId;
413413

414414
#ifdef WITH_ZMQ
@@ -1395,7 +1395,7 @@ int Readout::_start()
13951395
#endif
13961396
publishLogbookStats();
13971397
logbookTimer.reset(cfgLogbookUpdateInterval * 1000000);
1398-
maxTimeframeId = 0;
1398+
currentTimeframeId = undefinedTimeframeId;
13991399
countTimeframeId = 0;
14001400

14011401
// execute custom command
@@ -1504,29 +1504,30 @@ void Readout::loopRunning()
15041504
if (bc->size() > 0) {
15051505
if (bc->at(0)->getData() != nullptr) {
15061506
uint64_t newTimeframeId = bc->at(0)->getData()->header.timeframeId;
1507-
if (cfgTfRateLimitMode == 1) {
1508-
// use number of TF instead of computed TF id. Useful when replaying files with jumps in TF ids.
1509-
newTimeframeId = countTimeframeId + 1;
1510-
}
1511-
// are we complying with maximum TF rate ?
1512-
if (cfgTfRateLimit > 0) {
1513-
if (newTimeframeId > floor(startTimer.getTime() * cfgTfRateLimit) + 1) {
1514-
usleep(1000);
1515-
continue;
1507+
if (newTimeframeId != currentTimeframeId) {
1508+
// beginning of new TF detected: are we complying with maximum TF rate ?
1509+
if (cfgTfRateLimit > 0) {
1510+
uint64_t maxTimeframes = floor(startTimer.getTime() * cfgTfRateLimit) + 1; // number of TF allowed at this point
1511+
// mode 0: compare with TFid
1512+
// mode 1: use number of TF instead of computed TF id. Useful when replaying files with jumps in TF ids.
1513+
if ( ((cfgTfRateLimitMode == 0) && (newTimeframeId > maxTimeframes))
1514+
|| ((cfgTfRateLimitMode == 1) && (countTimeframeId >= maxTimeframes)) ) {
1515+
usleep(1000);
1516+
continue;
1517+
}
15161518
}
1517-
}
1518-
countTimeframeId++;
1519-
if (newTimeframeId > maxTimeframeId) {
1520-
maxTimeframeId = newTimeframeId;
1519+
countTimeframeId++;
1520+
currentTimeframeId = newTimeframeId;
15211521
#ifdef WITH_ZMQ
15221522
if (tfServer) {
1523-
tfServer->publish(&maxTimeframeId, sizeof(maxTimeframeId));
1523+
tfServer->publish(&currentTimeframeId, sizeof(currentTimeframeId));
15241524
}
15251525
#endif
15261526
gReadoutStats.counters.numberOfSubtimeframes++;
15271527
gReadoutStats.counters.currentOrbit = bc->at(0)->getData()->header.timeframeOrbitFirst;
15281528
gReadoutStats.counters.notify++;
15291529
}
1530+
// printf("Pushing TF #%d = %d\n", (int)countTimeframeId, (int)newTimeframeId);
15301531
}
15311532
for(auto const& b : *bc) {
15321533
updatePageStateFromDataBlockContainerReference(b, MemoryPage::PageState::InConsumer);

0 commit comments

Comments
 (0)