Skip to content

Commit df97d91

Browse files
committed
thread names
1 parent ccea698 commit df97d91

12 files changed

+43
-4
lines changed

src/ConsumerDataProcessor.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include <thread>
1616

1717
#include "Consumer.h"
18+
#include "ReadoutUtils.h"
19+
20+
#define CONSUMER_THREAD_NAME "processor"
1821

1922
const bool debug = false;
2023

@@ -78,6 +81,7 @@ class processThread
7881
// the loop which runs in a separate thread and calls fProcess() for each block in input fifo, until stop() is called
7982
void loop()
8083
{
84+
setThreadName(CONSUMER_THREAD_NAME "-loop");
8185
// printf("starting thread %d input=%p
8286
// output=%p\n",threadId,inputFifo.get(),outputFifo.get());
8387
// printf("processing thread %d starting\n",threadId);
@@ -305,7 +309,7 @@ class ConsumerDataProcessor : public Consumer
305309
// collector thread loop: handle the output of processing threads
306310
void loopOutput(void)
307311
{
308-
312+
setThreadName(CONSUMER_THREAD_NAME "-out");
309313
bool isActive = 0;
310314

311315
// lambda function that pushes forward next available bage

src/ConsumerDataSampling.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <fairmq/FairMQParts.h>
1919
#include <fairmq/FairMQTransportFactory.h>
2020
#include <thread>
21+
#include "ReadoutUtils.h"
2122

2223
class ConsumerDataSampling : public Consumer
2324
{
@@ -143,7 +144,10 @@ class ConsumerDataSampling : public Consumer
143144
}
144145

145146
private:
146-
void runDevice() { sender.RunStateMachine(); }
147+
void runDevice() {
148+
setThreadName("fmq-run-ds");
149+
sender.RunStateMachine();
150+
}
147151
};
148152

149153
std::unique_ptr<Consumer> getUniqueConsumerDataSampling(ConfigFile& cfg, std::string cfgEntryPoint) { return std::make_unique<ConsumerDataSampling>(cfg, cfgEntryPoint); }

src/ConsumerFMQ.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <fairmq/FairMQMessage.h>
1818
#include <fairmq/FairMQTransportFactory.h>
1919
#include <thread>
20+
#include "ReadoutUtils.h"
2021

2122
class FMQSender : public FairMQDevice
2223
{
@@ -142,7 +143,10 @@ class ConsumerFMQ : public Consumer
142143
}
143144

144145
private:
145-
void runDevice() { sender.RunStateMachine(); }
146+
void runDevice() {
147+
setThreadName("fmq-run-ds");
148+
sender.RunStateMachine();
149+
}
146150
};
147151

148152
std::unique_ptr<Consumer> getUniqueConsumerFMQ(ConfigFile& cfg, std::string cfgEntryPoint) { return std::make_unique<ConsumerFMQ>(cfg, cfgEntryPoint); }

src/ConsumerStats.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class ConsumerStats : public Consumer
221221
bool periodicUpdateThreadShutdown; // flag to stop periodicUpdateThread
222222
void periodicUpdate()
223223
{
224+
setThreadName("consumer-stats");
224225
periodicUpdateThreadShutdown = 0;
225226

226227
// periodic update

src/DataBlockAggregator.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ Thread::CallbackResult DataBlockAggregator::threadCallback(void* arg)
4141
return Thread::CallbackResult::Error;
4242
}
4343

44+
if (!dPtr->isThreadNamed) {
45+
#ifdef _GNU_SOURCE
46+
pthread_setname_np(pthread_self(), "aggregator");
47+
#endif
48+
dPtr->isThreadNamed = 1;
49+
}
50+
4451
if (dPtr->output->isFull()) {
4552
return Thread::CallbackResult::Idle;
4653
}

src/DataBlockAggregator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class DataBlockAggregator
115115
void reset(); // reset all internal buffers, counters and states
116116

117117
private:
118+
bool isThreadNamed = 0; // flag to set once thread name
118119
std::vector<std::shared_ptr<AliceO2::Common::Fifo<DataBlockContainerReference>>> inputs;
119120
AliceO2::Common::Fifo<DataSetReference>* output; // todo: unique_ptr
120121

src/ReadoutStats.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "ReadoutStats.h"
2121

2222
#include "readoutInfoLogger.h"
23+
#include "ReadoutUtils.h"
2324
#include "DataBlock.h"
2425
#include <string.h>
2526
#include <Common/Timer.h>
@@ -187,6 +188,8 @@ int ReadoutStats::stopPublish() {
187188

188189
void ReadoutStats::threadLoop() {
189190

191+
setThreadName("readout-stats");
192+
190193
// loop period in microseconds
191194
unsigned int loopPeriod = (unsigned int) 100000;
192195
unsigned long long t0 = 0;

src/SocketRx.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ SocketRx::~SocketRx(){
8888
}
8989

9090
void SocketRx::run() {
91+
#ifdef _GNU_SOURCE
92+
pthread_setname_np(pthread_self(), "socket-rx");
93+
#endif
94+
9195
int sockfd=-1;
9296
const char *sType="";
9397

src/SocketTx.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ SocketTx::~SocketTx()
5656

5757
void SocketTx::run()
5858
{
59+
#ifdef _GNU_SOURCE
60+
pthread_setname_np(pthread_self(), "socket-tx");
61+
#endif
5962

6063
// connect remote server
6164

src/ZmqClient.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ void ZmqClient::setPause(int pause)
115115

116116
void ZmqClient::run()
117117
{
118+
#ifdef _GNU_SOURCE
119+
pthread_setname_np(pthread_self(), "zmq-client");
120+
#endif
118121
for (; !shutdownRequest;) {
119122
int linerr = 0, zmqerr = 0;
120123
for (;;) {

0 commit comments

Comments
 (0)