473,417 Members | 1,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,417 software developers and data experts.

Bad performance multithread

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,

Jul 10 '06 #1
6 2804
"jmartin" <jo***************@cgi.comwrote in message
news:11**********************@p79g2000cwp.googlegr 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
Jul 10 '06 #2
"P.J. Plauger" <pj*@dinkumware.comwrote:
>"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
Jul 10 '06 #3
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

Jul 10 '06 #4
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/

Jul 10 '06 #5
"Roberto Waltman" <us****@rwaltman.netwrote in message
news:fs********************************@4ax.com...
"P.J. Plauger" <pj*@dinkumware.comwrote:
>>"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
Jul 10 '06 #6

"jmartin" <jo***************@cgi.comwrote in message
news:11**********************@p79g2000cwp.googlegr 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
Jul 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: haptiK | last post by:
Hello, can i use php to multithread mail() or something similar? in my company i need to send multiple copies of email to a few hundred ppl affilated and on my list. instead of calling mail...
4
by: dbmethods | last post by:
Could someone give a hint on how to do multithread programming with PHP scripting here? Thanks
0
by: Alice | last post by:
Hello I have four multithread windows applications(vb.net) interacting and running on the same machine(windows 2000 with .net framework 1.0). All of them start a new thread each time Filewatcher's...
0
by: r_obert | last post by:
Hello, I'm trying to create a worker thread for my VC++ program, and was wondering whether I should be linking with the Multithread /MT or Multithread DLL /MD option? I'm not quite sure, in...
3
by: QQ | last post by:
I am new here and got lost on a multithread C++ system source codes Thanks a lot!
4
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a...
2
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting...
9
by: wdwedw | last post by:
I have included all the source codes in the attached MyTest.zip (http://www.codeguru.com/forum/attachment.php?attachmentid=11218) There are three projects: VBTestCOM project is a apartment...
2
by: tikcireviva | last post by:
Hi Guys, I've done a mulithread queue implementation on stl<queue>, my developement environment is on VC6 as well as FC3. Let's talks about the win32 side. The suspected memory leak is find...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.