Concurrent Message Service M. Clemencic CERN - LHCb Forum on Concurrent Programming Models and Frameworks 24-10-2012 M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 1 / 11
Outline Introduction 1 Gaudi Concurrent Message Service 2 Considerations and Summary 3 M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 2 / 11
Introduction Outline Introduction 1 Gaudi Concurrent Message Service 2 Considerations and Summary 3 M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 3 / 11
Introduction The problem Applications need logging tools Gaudi uses the class MessageSvc Logging must be concurrency-friendly concurrent message pushing sequential message handling preserve order avoid bottlenecks M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 4 / 11
Gaudi Concurrent Message Service Outline Introduction 1 Gaudi Concurrent Message Service 2 Considerations and Summary 3 M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 5 / 11
Gaudi Concurrent Message Service Requirements Drop-in replacement message reporting is performed by only one method Concurrent input / sequential output central message queue Avoid interference with Algorithms/Modules execution deferred reporting execution in another thread Lock-free implementation use existing concurrency libraries/tools M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 6 / 11
Gaudi Concurrent Message Service Requirements Drop-in replacement message reporting is performed by only one method Concurrent input / sequential output central message queue Avoid interference with Algorithms/Modules execution deferred reporting execution in another thread Lock-free implementation use existing concurrency libraries/tools M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 6 / 11
Gaudi Concurrent Message Service Requirements Drop-in replacement message reporting is performed by only one method Concurrent input / sequential output central message queue Avoid interference with Algorithms/Modules execution deferred reporting execution in another thread Lock-free implementation use existing concurrency libraries/tools M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 6 / 11
Gaudi Concurrent Message Service Requirements Drop-in replacement message reporting is performed by only one method Concurrent input / sequential output central message queue Avoid interference with Algorithms/Modules execution deferred reporting execution in another thread Lock-free implementation use existing concurrency libraries/tools M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 6 / 11
Gaudi Concurrent Message Service Implementation � TBB & C++11 Using Intel R std::atomic tbb::concurrent_queue tbb::task tbb::task::enqueue Generic SerialTaskQueue from TBB pattern Local Serializer M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() delete wait completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Algorithm’s first message. delete wait completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Algorithm’s second message. delete wait completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Queue is free: schedule new task. delete wait completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Report task started. delete wait completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Queue is busy: just append. delete wait completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Report task completed: delete wait schedule new task. completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Report task may start before the delete wait completed previous one returned. destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() The destructor of SerialTaskQueue delete wait completed is blocking. destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Report task completed: delete wait stop waiting. completed destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Gaudi Concurrent Message Service Implementation : Algorithm : MessageSvc : SerialTaskQueue : TBB � TBB & C++11 Using Intel R new std::atomic Processing Processing message1 tbb::concurrent_queue add() task::enqueue tbb::task report() tbb::task::enqueue Generic SerialTaskQueue message2 add() from TBB pattern Local Serializer completed task::enqueue report() Delete may complete before the delete wait completed task returns. destroyed M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 7 / 11
Considerations and Summary Outline Introduction 1 Gaudi Concurrent Message Service 2 Considerations and Summary 3 M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 8 / 11
Considerations and Summary Considerations (1/2) SerialTaskQueue is relatively simple and lightweight can be used for other complex tasks Concept available in libdispatch not tried yet enqueue vs. spawn vs. continuation continuation → run immediately in the same thread spawn → run ASAP , better if in the same thread enqueue → run later, when you have time M. Clemencic (CERN - LHCb) Concurrent Message Service 24-10-2012 9 / 11
Recommend
More recommend