473,566 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2816
"jmartin" <jo************ ***@cgi.comwrot e in message
news:11******** **************@ p79g2000cwp.goo glegroups.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.programmin g.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****@rwaltma n.netwrote in message
news:fs******** *************** *********@4ax.c om...
"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 "performanc e" in a more selfish manner.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 10 '06 #6

"jmartin" <jo************ ***@cgi.comwrot e in message
news:11******** **************@ p79g2000cwp.goo glegroups.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
8598
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 over and over again i would like to thread this process. could someone point me to some documentation or perhaps an example of
4
7007
by: dbmethods | last post by:
Could someone give a hint on how to do multithread programming with PHP scripting here? Thanks
0
1602
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 created or deleted event is fired. One of these application writes data into word documents also in multithread fashion. Sometimes the created and...
0
1849
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 layman's terms, what the difference is. When I build with Multithread DLL, the linker complains about not being able to find a bunch of "unresolved...
3
3081
by: QQ | last post by:
I am new here and got lost on a multithread C++ system source codes Thanks a lot!
4
7070
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 incoming connection,the relative code snipprt as following:: private IPAddress myIP=IPAddress.Parse("127.0.0.1"); private IPEndPoint myServer;...
2
26487
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 for a incoming connection,the relative code snipprt as following:: private IPAddress myIP=IPAddress.Parse("127.0.0.1");
9
1575
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 threaded DLL, it has one function doing a stored procedure call. This DLL will be called from C++ multithread. C++ test project is a ATL multithreaded...
2
5285
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 after I've run through my unit test cases. Test Case:
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.