Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

C/C++

Lock-free Interprocess Communication


Performance Testing

Algorithm 2 was compared to Algorithm 3 and a standard version of this algorithm. This test involves passing 10,000,000 integer values from one thread to another. The standard algorithm performs all required locking when it accesses shared resources. Locking is performed for every passing integer.

  Standard Algorithm Algorithm 2 (Light Pipe) Algorithm 3 (Cache Line Optimised Light Pipe)
Dell notebook 1.6 GHz 11.5 sec 0.18 sec 0.22 sec
Dell server 2 processors with hyper threading technology (4 virtual processors) 243 sec 0.35 sec 0.07 sec
Table 1: Performance comparison of standard algorithm, Algorithm 2 and Algorithm 3.

I would not consider this comparison very fair for standard applications because we usually do not send information in small chunks from one process to another, but for some applications (like routers or switches) this technique may bring some benefits. For example, consider a few specialized processors which perform pipelined data processing (Figure 6).

Figure 6: Pipelined data processing.

Then data can be passed between these processors using the proposed mechanism. It should improve overall performance in case of high load and probably decrease latency time in case of low load.

Table 2 shows Algorithm 4 compared with standard version of this algorithm. The testing procedure in this case involves running 8 threads. Each thread reads from the registry 1,024,000 times and updates the registry 1,000 times.

  Standard version of Algorithm 4 Algorithm 4 (Lock-free Read-optimized Registry)
Dell notebook 1.6 GHz 3.4 sec 3.5 sec
Dell server, 2 processors 3.2 GHz with hyper threading technology (4 virtual processors) 37 sec 1.2 sec
Table 2: Performance comparison of standard and optimized versions of Algorithm 4.

The lock-free algorithm does not provide any benefits on single-processor systems, but on a multi-processor system it outperformed the standard algorithm by about a factor of 30. Since multiprocessor systems are becoming mainstream the described technique or its variations may bring considerable benefits for applications which use it.

References:

  1. Chandler , Dean. Reduce False Sharing in .NET*, http://www.intel.com/cd/ids/ developer/asmo-na/eng/193679.htm?page=1
  2. Alexandrescu, Andrei. Lock-free data structures, C/C++ Users Journal, October 2004


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.