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 ▼

Cameron and Tracey Hughes

Dr. Dobb's Bloggers

Bubble Sort Too Slow? Add Concurrency!

October 05, 2010

Which comes first, the blackboard structures or the formal languages or the partitioning or the high-level paradigms or the AI-incomplete issue or the questions about algorithm performance?

In the spirit of concurrency, we've kind-a been time slicing them all. Each one has had a quantum or two on the CPU. But we've made certain assumptions.

The first assumption is that performance has been improved as much as it practically can be using the sequential model that is currently inplace. But time and again we find that we assumed too fast. While testing one of the modules that we are retrofitting, we're running the basic time() function on it just to get a sense of wall-clock time as we clean it up. But we find it's taking 2-3 minutes to run. We dig a little deeper and find that the module is building a tree that will later be searched by another module in the system. But the tree building algorithm is mediocre at best. There are much better algorithms available. So before we went any further, we switched algorithms. After the switch we tested the module again. The minutes changed to 10-15 seconds! Of course I had to ask the question "Now why are we trying add concurrency to this module again?"

The processor wars spoiled a lot us in development. I guess we ceased to try to improve algorithms or look for better algorithms in favor of just waiting for the newest processor to speed up our programs and systems. After what I saw this weekend, I can't help but wonder how many retrofitting projects are going on out there just to speed up a poor choice or outdated choice of algorithms and and data structures. Yes, multicore is here, and it's here to stay, but ...

Don't add complexity to the architecture of the system if a better sequential algorithm or improved sequential algorithm will get you the speed up you need.

Formal language will help us deal with the complexity of concurrent designs, but let's not deal with the complexity until we absolutely have to. There are some basic adages in software development. Make sure it's correct before you worry about making it fast. Well to this we add:

Make sure you take advantage of the sequential speed available before you worry about adding concurrency and parallelism.

Sometimes this is just a simple matter of revisiting the search, sort, insert, update, and delete algorithms that a module is using. In other cases we're finding inefficient file handling is at the heart of the problem. All of these things should be dealt with prior to committing to a retrofitting project....

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.