harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "cyang.cq" <cyang...@gmail.com>
Subject [drlvm][thread]scalability problem
Date Mon, 24 Sep 2007 07:45:15 GMT
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.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message