Hello,
Thanks a lot for the finding. I've spend a while trying to understand the
reason of such behavior, no much progress so far. But I found out that such
behavior is only appeared in interpreter or JET modes, so quick fix for such
situation would be using Harmony with option -Xem:opt. In opt mode I got
better than linear scalability:
java -Xem:opt MT 9000000000 1
Total time: 20219
java -Xem:opt MT 9000000000 2
Total time: 10140
java -Xem:opt MT 9000000000 4
Total time: 4625
java -Xem:opt MT 9000000000 8
Total time: 2485
java -Xem:opt MT 9000000000 16
Total time: 2500
I used Dual processor Quad Core Xeon(r) 5355 (8 Cores total) 2.67 GHz, 4 Gb of
RAM with Windows Server 2003 OS and Harmony r571439.
I'll do some deeper analysis on reasons of such behavior on JET and
interpreter.
Thanks,
Yuri
On 9/24/07, cyang.cq <[EMAIL PROTECTED]> wrote:
>
> Hi, all
> The scalability of the program below is surprising on M2.
> This program only starts several threads to share the work
> of doing a number of additions.
>
> MT.java:
>
> public class MT extends Thread{
>
> static long result = 0;
> long len = 0;
> public MT(long len){
> this.len = len;
> }
>
> public void run(){
> long total = 0;
> for(long i = 0; i < len; ++i){
> total += 1;
> }
> result = total;
> }
>
> public static void main(String[] args) throws InterruptedException {
> long totalWork = Long.parseLong(args[0]);
> int numThreads = Integer.parseInt(args[1]);
>
> long work = totalWork / numThreads;
>
> MT[] v = new MT[numThreads];
> for(int i = 0; i < numThreads; ++i){
> v[i] = new MT(work);
> }
>
> long start = System.currentTimeMillis();
> for(int i = 0; i < numThreads; ++i){
> v[i].start();
> }
> for(int i = 0; i < numThreads; ++i){
> v[i].join();
> }
> long dur = System.currentTimeMillis() - start;
>
> System.out.println("Total time: " + dur);
> }
>
> }
>
> Run it on 5.0M2:
> CMD OUTPUT
> java MT 9000000000 1 Total time: 411325
> java MT 9000000000 2 Total time: 1052861
> java MT 9000000000 4 Total time: 915545
> java MT 9000000000 8 Total time: 589672
> java MT 9000000000 12 Total time: 678815
> java MT 9000000000 16 Total time: 621097
>
>
> Run it on sun jdk 1.5.0_08:
> CMD OUTPUT
> java MT 9000000000 1 Total time: 10356
> java MT 9000000000 2 Total time: 5182
> java MT 9000000000 4 Total time: 2601
> java MT 9000000000 8 Total time: 1453
> java MT 9000000000 12 Total time: 1004
> java MT 9000000000 16 Total time: 782
>
>
>
> My configuration is:
> OS: Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
> Kernel 2.6.9-42.ELlargesmp on an x86_64
> CPU: 8 X Dual-Core AMD Opteron 2.6G
> Mem: 16G
> drlvm: Apache Harmony 5.0M2 JRE for 32-bit Linux
> for systems with libstdc++.so.5
> sun jdk: jdk-1_5_0_08-linux-i586
>
>
> Any suggestions? Have this been fixed already since M2?
>
> Thanks in advance.