Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Bad performance multithread

Reply
Thread Tools

Bad performance multithread

 
 
jmartin
Guest
Posts: n/a
 
      07-10-2006
Hi,

I have made a multithread version of a program (load a file into
database), and with two processors I get the double of time in the
multithread than in the process (unithread) version.

I have done the test of creating a unique thread that does the same
code that the process version of the program and it takes more time
that the process without creating the thread.

It seems that the thread get worse performance that the process alone,
and that two processors isn't good enough to get a performance
improvement with multithread overhead.

Is this normal? The program requires threads syncronization and that
can get performance worse.

We are using RogueWave threads module under AIX.

Thanks in advance,

 
Reply With Quote
 
 
 
 
P.J. Plauger
Guest
Posts: n/a
 
      07-10-2006
"jmartin" <> wrote in message
news: oups.com...

> I have made a multithread version of a program (load a file into
> database), and with two processors I get the double of time in the
> multithread than in the process (unithread) version.
>
> I have done the test of creating a unique thread that does the same
> code that the process version of the program and it takes more time
> that the process without creating the thread.
>
> It seems that the thread get worse performance that the process alone,
> and that two processors isn't good enough to get a performance
> improvement with multithread overhead.
>
> Is this normal? The program requires threads syncronization and that
> can get performance worse.
>
> We are using RogueWave threads module under AIX.


You don't introduce multithreading to improve *performance* but to
improve *responsiveness*. There's a difference. Having said that, I
observe that performance losses as bad as you describe can usually
be dramatically improved by a more judicious use of synchronizing
logic. (Watch where you put your thread locks.)

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com


 
Reply With Quote
 
 
 
 
Roberto Waltman
Guest
Posts: n/a
 
      07-10-2006
"P.J. Plauger" <> wrote:
>"jmartin" wrote in message
>> I have made a multithread version of a program ...

> and with two processors I get the double of time in the
>> multithread than in the process (unithread) version.
>>...

>
>You don't introduce multithreading to improve *performance* but to
>improve *responsiveness*...


That's correct in uniprocessor systems. The OP mentions "two
processors", in which case some programs (not all) can get a
performance boost by multithreading. (But of course, you know that.)

To the OP: try also posting in comp.programming.threads
 
Reply With Quote
 
Tom St Denis
Guest
Posts: n/a
 
      07-10-2006
jmartin wrote:
> Is this normal? The program requires threads syncronization and that
> can get performance worse.


Are you asking if two parallel threads competing for the same resource
will be less efficient then one thread using the resource fully?

YES IT WILL BE SLOWER

Tom

 
Reply With Quote
 
websnarf@gmail.com
Guest
Posts: n/a
 
      07-10-2006
jmartin wrote:
> I have made a multithread version of a program (load a file into
> database), and with two processors I get the double of time in the
> multithread than in the process (unithread) version.
>
> I have done the test of creating a unique thread that does the same
> code that the process version of the program and it takes more time
> that the process without creating the thread. [... etc]


Optimizing algorithms on multithreaded systems can be hard. If you
split an operation on an array, for example, then you will need each
processor to have half of the memory from that array, which means that
inevitably which may have started as a single continguous array has to
be at least half copied into the cache of the other processor. This is
ok if your algorithm is very expensive in comparison to the cost of
copying the array, for example. But its something trivial like just
summing up the elements of the array, I could see how it could easily
be slower, or at least no faster, on a single threaded machine.

Optimization on multithreading system, still relies good algorithm
design and the use of tools such as profilers to isolate performance
bugs. In that sense, its the same as single threading. But you have
to be aware of hidden performance problems such as increased memory
locality issues such as I have described above.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/

 
Reply With Quote
 
P.J. Plauger
Guest
Posts: n/a
 
      07-10-2006
"Roberto Waltman" <> wrote in message
news:...

> "P.J. Plauger" <> wrote:
>>"jmartin" wrote in message
>>> I have made a multithread version of a program ...

>> and with two processors I get the double of time in the
>>> multithread than in the process (unithread) version.
>>>...

>>
>>You don't introduce multithreading to improve *performance* but to
>>improve *responsiveness*...

>
> That's correct in uniprocessor systems. The OP mentions "two
> processors", in which case some programs (not all) can get a
> performance boost by multithreading. (But of course, you know that.)


Yes, I almost added that qualifier. At the risk of quibbling, however,
I still feel obliged to point out that one program can get better
*response* (quicker termination) by using two or more processors, at
the expense of using somewhat more total processing time (worse overall
*performance*). On a heavily loaded system, you're simply stealing from
the commonweal. On a system dedicated to one person, and under utilized,
you can arguably define "performance" in a more selfish manner.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com


 
Reply With Quote
 
Kevin Sproule
Guest
Posts: n/a
 
      07-11-2006

"jmartin" <> wrote in message
news: oups.com...
> Hi,
>
> I have made a multithread version of a program (load a file into
> database), and with two processors I get the double of time in the
> multithread than in the process (unithread) version.
>
> I have done the test of creating a unique thread that does the same
> code that the process version of the program and it takes more time
> that the process without creating the thread.
>
> It seems that the thread get worse performance that the process alone,
> and that two processors isn't good enough to get a performance
> improvement with multithread overhead.
>
> Is this normal? The program requires threads syncronization and that
> can get performance worse.
>
> We are using RogueWave threads module under AIX.
>
> Thanks in advance,
>


Have you determined that the process (single or multi-threaded) is CPU bound
and not I/O bound? If it is I/O bound then running multiple threads would
make it more I/O bound and therefore slower.

Kevin Sproule


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby 1.9.2 : Io performance when application use multithread Regis d'Aubarede Ruby 8 12-17-2010 10:56 AM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 12 02-23-2005 03:28 AM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 0 02-19-2005 01:10 AM
Multithread or Multithread DLL? r_obert@REMOVE_THIS.hotmail.com C++ 0 11-27-2004 04:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57