1

Hey guys I am working on a concurrent program in Scala and I am running some tests to check efficiency but I seem to get some really bizarre numbers.

In every test I increase the number of "workers" or processes spawned off. I am expecting to find an increase in running time as these processes increase up from 1 up to the point where the communication overhead and the race conditions get high enough to cancel it out. So for example I am expecting to see something like:

Processes ------ 1 ------ 2 ------ 3 ------ 4 ------ 5 ------ 6 ------ 7

Runtime(sec) ---- 3 ------- 2.5 ------- 2 ------- 1.5 ------- 2 ------- 2.5 ------- 3

In any case what I would like to ask is if anyone knows how many threads can an Intel Core i5-430M processor hold. I know it typically has EDIT: 2 cores and 4 threads. Does that mean that performance should start getting worse after spawning 5 and more processes? Like the above example?

Any help would be appreciated.

1
  • My concurrent benchmark with actors showed a strange behavior (of course having no other processes using the CPU): Using 6 threads on 6 cores yields only 4% (should be 20%) more performance compared to using 5 threads. But 5 threads 22% (should be 25%) compared to 4 threads. And 4 threads 85% (should be 100%) compared to 2 threads. Commented Mar 25, 2011 at 12:36

2 Answers 2

4

Use Runtime.getRuntime().availableProcessors(). Generally for a CPU intensive application there is no gain in using more threads than number of available cores/CPUs. However, if some threads are blocking in IO operations for example you can benefit from having more threads.

Note that whenever possible you should use the java.util.concurrent library instead of writing your own parallelization/concurrency code.

Sign up to request clarification or add additional context in comments.

4 Comments

What would Runtime.getRuntime().availableProcessors() this do? I am not sure. Also I am making a huge concurrent program in Scala so I am implementing all the details for it.
It tells you how many cores are available in the platform. There's no point in creating more threads than this number for a CPU intensive application. However, you should use java.util.concurrent instead as it does all this for you automatically.
Oh, yes that is really useful thnx! :) I am still not sure how do you expect me to use java.util.concurrent. I mean it's a whole class, what do you mean use it? Use what and what for?
Have a look at java.util.concurrent.Executor and implementing classes. These are what you want to do the work.
0

http://ark.intel.com/Product.aspx?id=43537

This spec from Intel says that number of cores are 2 and number of threads are 4.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.