Why doesn't performance increase too mcuh in multi threading? Please help

A

AliRezaGoogle

Dear members
I am working with a 2000 GH P4 Intel, and 512GB RAM.

I have a long list matrix 3000 * 15,000 of type double.
I have a calculation procedure which can be executed on any single
element of the matrix. Regarding to nature of this procedure, it is
possible to run procedure on every element independently. I designed
30 threads. Every thread runs same procedure on equal portion of the
matrix. For example rows from 0 to 100 are dedicated to thread #1 to
execute some calculation on them. There is no data or function
dependency. The only shared data is that matrix.

Before threading, I wrote the program in sequential manner. That, all
of the elements were calculated one by one each after each without any
parallelism.
After threading, I expected to see significant increase in speed of
execution. While I have 30 workers working concurrently. But the speed
increased a little and too less that what was expected.

What is the reason? How can I increase performance much more?
 
N

Nicholas Paldino [.NET/C# MVP]

Are you running on a multi core/processor system? If not, then
multithreading isn't going to do much for you. When running on a single
processor/core system, multiple threads are handled by giving out time
slices to each thread that wants to perform some processing. It's not until
you have more than one processor that you can actually do things in
parallel.

From what you stated, it doesn't look like you have a multiple processor
system. If you want to see an improvement, you will have to test on a
machine with multiple processors.

If you do have multiple processors, then you might be processing chunks
that are too small, and you are performing too many context switches,
negating any benefit that multiple processors will bring you.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


AliRezaGoogle said:
Dear members
I am working with a 2000 GH P4 Intel, and 512GB RAM.
After threading, I expected to see significant increase in speed of
execution. While I have 30 workers working concurrently. But the speed
increased a little and too less that what was expected.

What is the reason? How can I increase performance much more?


Think about it, you have only one processor (from your post at least) but
now you have two processes compiting for that same processor, of course the
performance will be less.
Multithreading helps in a number of situations, like when you have an app
that needs to be responsible to the user while doing some work in the back.
As the UI thread should not consume a lot the worker thread can work while
keeping the app responding to the user input.

In cases where you have a calculation intensive process having threads can
only help IF you have more than one processor, otherwise is an overload.
 
U

UL-Tomten

After threading, I expected to see significant increase in speed of
execution.

Why? Is there something in the nature of the calculations that
suggests you are wasting any time while performing them?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top