Project

General

Profile

Actions

Task #2513

closed

Optimize multi-threaded logging using lock-free queue and separate thread

Added by Alex Afanasyev about 9 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Core
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
12.00 h

Description

To ensure proper logging in a multi-threaded environment, currently we use std::lock_guard to prevent any race conditions.

This process can be optimized with the use of lock-free queue(s):

  • individual threads (NFD and RIB) write logs, line by line, into lock-free queue(s)
  • separate thread that pulls log lines from queue(s), and writes them into std::clog
|---------------|
| NFD thread    |  queue  |------------------|
|          push >>>>>>>>>>> pop              |
|---------------|         |                  |
                          |  logging thread  >> std::clog
|---------------|         |                  |
|          push >>>>>>>>>>> pop              |
| RIB thread    |  queue  |------------------|
|---------------|

A lock-free queue, such as boost::lockfree::queue or boost::lockfree:spsc_queue, from Boost.Lockfree library, should be used.
On a platform where Boost.Lockfree library is not available, a regular queue protected by std::lock_guard could be used.

The design of logging thread should be flexible about the number of log-generating threads.
In the future, when we need to add a third log-generating thread to nfd process, the logging thread should not require a major change.


Files

config.log (55.7 KB) config.log Yumin Xia, 03/06/2016 10:54 PM
20160313235309.tgz (127 KB) 20160313235309.tgz integ 2707,15 Junxiao Shi, 03/14/2016 10:40 AM
20160316142459.tgz (169 KB) 20160316142459.tgz integ master Junxiao Shi, 03/16/2016 10:47 AM
20160316131536.tgz (125 KB) 20160316131536.tgz integ 2707,16 Junxiao Shi, 03/16/2016 10:47 AM

Related issues 3 (1 open2 closed)

Related to NFD - Task #2489: Merge nrd into nfdClosedAlex Afanasyev

Actions
Blocks ndn-cxx - Feature #3553: Logging facility: bounded record queueNew

Actions
Blocked by NFD - Task #3599: Drop build support for Ubuntu 12.04ClosedDavide Pesavento04/21/2016

Actions
Actions

Also available in: Atom PDF