1. This forum section is a read-only archive which contains old newsgroup posts. If you wish to post a query, please do so in one of our main forum sections (here). This way you will get a faster, better response from the members on Motherboard Point.

Performance anomaly on T5140

Discussion in 'Sun Hardware' started by thegman, Jul 11, 2008.

  1. thegman

    thegman Guest

    Today, to kill some time, I wrote some Java to make 96 threads, do
    some crypto stuff, and put the results into a Hashtable. I did this
    primarily to pass time and also to see how the T5140 performed with
    this number of threads. To compare results, I ran the same program on
    my G5 Mac. The results surprised me a bit as they were roughly the
    same. It seems odd to me that a 12 core T5140 would be about the same
    as a 2x2GHz Power Mac G5, when every benchmark I read would say that
    the T5140 would be very significantly quicker, especially under such
    heavily threaded loads. I have also run some other programs on the
    T5140, and it is indeed over twice as fast as the G5, sometimes 3 or 4
    times quicker.

    Any ideas?

    Cheers

    Garry
     
    thegman, Jul 11, 2008
    #1
    1. Advertisements

  2. thegman

    AGT Guest

    Show us this java code of yours...?
    maybe its not doing what you think.
    Id be happy to test it on my 5120 eval..

    I tested it vs, an M4000 yesterday (openssl speed -engine pkcs11 rsa)
    and up to 2048 bits the 5120 beat the heck out of the M4K...
     
    AGT, Jul 11, 2008
    #2
    1. Advertisements

  3. thegman

    thegman Guest

    No problem... There are two classes, in between the asterisks.


    ****

    import java.util.Hashtable;
    import java.util.Random;


    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.security.DigestInputStream;
    import java.security.DigestOutputStream;
    import java.security.MessageDigest;
    import java.security.Security;



    public class Threaded extends Thread {

    Hashtable _hash;
    Hashtable _global_hash;

    public Threaded (Hashtable hash) {

    _global_hash = hash;

    _hash = new Hashtable();

    }


    public static String crypto(String text_in) {

    try {
    byte[] input = text_in.getBytes();
    //System.out.println("input : " + new String(input));
    MessageDigest hash = MessageDigest.getInstance("SHA1");

    ByteArrayInputStream byteArrayInputStream = new
    ByteArrayInputStream(input);
    DigestInputStream digestInputStream = new
    DigestInputStream(byteArrayInputStream, hash);
    ByteArrayOutputStream byteArrayOutputStream = new
    ByteArrayOutputStream();

    int ch;
    while ((ch = digestInputStream.read()) >= 0) {
    byteArrayOutputStream.write(ch);
    }

    byte[] newInput = byteArrayOutputStream.toByteArray();
    //System.out.println("in digest : " + new
    String(digestInputStream.getMessageDigest().digest()));

    byteArrayOutputStream = new ByteArrayOutputStream();
    DigestOutputStream digestOutputStream = new
    DigestOutputStream(byteArrayOutputStream, hash);
    digestOutputStream.write(newInput);
    digestOutputStream.close();

    return new String(digestOutputStream.getMessageDigest().digest());
    } catch (Exception e) {
    System.out.println("Exception in crypto()");
    return "fail";
    }
    }

    public void run() {

    int counter = 0;

    System.out.println("Started thread "+getName());

    while (counter < 2000) {
    Random generator = new Random( counter );

    _hash.put(getName()
    +String.valueOf(counter),"BLAH"+crypto(getName()));

    counter++;

    }

    _global_hash.put(getName(),_hash);

    System.out.println("Finished thread "+getName());


    }



    }

    ****


    import java.util.Hashtable;
    import java.util.Vector;




    public class TestThreads {


    public static void main(String args[]) {

    Hashtable hash = new Hashtable();
    Vector threads = new Vector();

    int counter = 0;
    while (counter < 96) {
    Threaded t = new Threaded(hash);
    t.setName(String.valueOf(counter));
    t.start();
    threads.add(t);
    counter++;
    }

    counter = 0;

    while (counter < 96) {
    Threaded t = (Threaded) threads.get(counter);
    try {
    t.join();
    } catch (Exception e) {
    e.printStackTrace();
    }
    counter++;
    }


    //System.out.println(hash);



    }

    }


    *****


    Would be interested to see how that goes on different machines, it's
    changed since the first post, now it's going much faster on the Mac...
    As it stands right now, it runs in about 5 secs on the G5, and 10 secs
    on the 5140, both much slower if I use -Xint, but the Mac still edges
    it.

    Going by my history, I've probably made a head-slapping mistake, but
    we'll see...

    Cheers

    Garry
     
    thegman, Jul 11, 2008
    #3
  4. thegman

    thegman Guest

    I've done more testing, and I'm wondering what sort of performance
    penalty using Java threads has? I made my program take an argument of
    number of threads to make, and tried running 100 threads, and then 10
    processes at the same time each with 10 threads, the results are like
    so:


    Sun T5140 2x6x1.2GHz

    -bash-3.00$ java TestThreads 100
    ############################################## (100 threads (9202
    ms.) )

    -bash-3.00$ java TestThreads 10 & java TestThreads 10 & java
    TestThreads 10 & java TestThreads 10 & java TestThreads 10 & java
    TestThreads 10 & java TestThreads 10 & java TestThreads 10 & java
    TestThreads 10 & java TestThreads 10

    ############# (10 threads (2798 ms.) )
    ############## (10 threads (2802 ms.) )
    ############# (10 threads (2799 ms.) )
    ############## (10 threads (2866 ms.) )
    ############## (10 threads (2880 ms.) )
    ############## (10 threads (2918 ms.) )
    ############## (10 threads (2926 ms.) )
    ############## (10 threads (2918 ms.) )
    ############## (10 threads (2944 ms.) )
    ############## (10 threads (2944 ms.) )

    I only make one call to a synchronized method, and that's at the end
    of each thread, and extremely does very minimal work. So it would seem
    that processes run much faster than threads on the T5140, which is not
    terribly surprising as there must be all kinds of locks in there which
    I didn't write and don't know about, but the difference is pretty big,
    and also those locks would still apply on my Power Mac G5, and this
    still manages pretty good performance with 100 threads:

    (Power Mac G5, 2x2GHz)
    ################ (100 threads (3384 ms.) )

    For most other multi-thread/process apps, the T5140 is a lot faster
    than the G5, any ideas what's going on? I can mail anyone the source
    code for my test program.

    Cheers

    Garry
     
    thegman, Jul 16, 2008
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.