Re: Increase WinXP/jre CPU usage?
Steve Brecher wrote:
Patricia Shanahan <pats@acm.org> wrote:
Chris Uppal wrote:
Patricia Shanahan wrote:
I would look at it in terms of throughput. Single thread does one
job per 185 seconds. Two jobs does about 2 jobs per 460 seconds = 1
job per 230 seconds.
The two job throughput is 230/185 = 1.24 times the single thread
throughput, a 24% gain.
Loss ;-)
-- chris
Correct. :-)
OK, so I won't hope for improvement by multi-threading on my P4 with
"Hyper-Threading Technology."
But looking ahead to other hardware...
In a routine called from inner loops -- this routine is called 800 million
times in the timing test case I've been using -- I have something like this
(schematically):
for (int i = 0; i < n; i++) { //n is typically a single-digit value (min 2)
result[i] = AStaticMethod(arg[i]);
...
}
What would be the lowest-overhead way to multi-thread the executions of
AStaticMethod?
Rule #1 for optimizing loop nests, commonly followed by optimizing
compilers:
*** Examine the whole loop nest as a unit. ***
An innermost loop with small iteration count is not usually the best
place to begin optimization.
Are you using a "client" or "server" version of Java? My understanding
is that the "server" JVMs do more routine optimizations than the
"client" versions.
If you are not using a "server" JVM I would try that first. Never do for
yourself work the compiler can do for you.
Even without going multi-threaded, many loop nests can be made more
efficient by changing the order of the loops, loop unrolling etc.
Patricia