We're using the Sun 1.5.0_06 JVM on RedHat (AS). The box has 4 CPUs,
they're all available and get some load (i. e. OS recognized them and
they work). But al our JVM max out by just "digesting" a single CPU, i.
e. any JVM maxes out at 25% of the system load.
Using a simple CPU-eater program that runs multiple thread I was able
to:
- "digest" 2 cores on Win XP
- "digest" 2 cores on Max OS X (Intel)
- still only 1 (!) CU on the Linux server
Where's the problem? Anyone else having the same issue? There is just
one particularity to the Lunix installation, the Xeon CPUs are 64bit
but we're using the 32bit version of the OS (and JV; and all other
stuff).
Anyone seein the same problem.
For testing purposes this is the code I used (will digest up to 3 CPU
cores for max 30 secs.):
package test;
public class CpuBound {
public static void main(String[] args) throws InterruptedException {
Thread th1 = new Thread(new Eater());
Thread th2 = new Thread(new Eater());
Thread th3 = new Thread(new Eater());
th1.start();
th2.start();
th3.start();
int joinTime = 10*1000;
System.out.println("Joining " + th1);
th1.join(joinTime);
System.out.println("Joining " + th2);
th2.join(joinTime);
System.out.println("Joining " + th3);
th3.join(joinTime);
System.out.println("End");
System.exit(-1);
}
static class Eater implements Runnable {
public void run() {
Thread.yield();
for( long l = Long.MIN_VALUE; l < Long.MAX_VALUE; l++) {
long sprloink = l*l;
if(sprloink > l) {
sprloink = l;
} else {
sprloink-=l;
}
}
}
}
}
Chris Uppal - 25 Jul 2006 09:26 GMT
> We're using the Sun 1.5.0_06 JVM on RedHat (AS). The box has 4 CPUs,
> they're all available and get some load (i. e. OS recognized them and
> they work). But al our JVM max out by just "digesting" a single CPU, i.
> e. any JVM maxes out at 25% of the system load.
Presumably the JVM hasn't "realised" that it's running on a multi-CPU system.
What does
Runtime.getRuntime().availableProcessors()
return ?
-- chris