Name: dgC58589 Date: 12/12/97
BTW: You do not have a pull down for Solaris 2.5.1 x86
This is for 2.5.1 x86, JKD 1.1.5
-------------------------------------------------
I have noticed that the native threads are much slower than green threads
on Solaris x86 with the JDK 1.1.5
In this directory you will find a simple 'ping-pong' test that starts a new
thread each time it get a ping() method. The new thread send a ping()
message to another Ping instance, which starts a thread that sends a ping()
message back.
In green threads the CPU spends about 4.03 seconds (averaged) in sys., while
the native threads spent 19.03 (average) seconds in sys. That is 4.72 times
more time in sys.
In green threads the CPU spent 31.89 sec in user, while native spent 49.74.
In green threads the CPU spent 36.61 real, native spent 69.48 seconds.
green native times slower notes
---- ----- ------ ------------- --------------------------
real 36.61 69.48 1.89 almost 2 times
user 31.89 49.74 1.56
sys 4.03 19.03 4.72 almost 5 times
Source code, README, and time test can be found in
the tar file at
http://www.jmaca.com/download/bugs/bug1.tar
file PingTest1.java
import java.io.*;
import java.util.*;
public class PingTest1
{
int i = 0;
int iterations;
PingTest1 pong;
public Date startDate = new Date();
FileWriter fw;
public PingTest1 ( String fileName, int iterations )
{
this.iterations = iterations;
try
{
fw = new FileWriter ( fileName );
}
catch ( Exception e )
{
System.out.println("err: " + e.getMessage());
e.printStackTrace();
}
}
public void
setStartDate ()
{
startDate = new Date();
}
/**
* Starts a thread that will send a ping() message to the object
* registered as "pong".
* <P>
* The reason for starting a thread, is to allow the method
* to return. Otherwise we would be recursive.
*/
public void
ping ( )
{
if ( i++ > this.iterations )
{
pong.quit();
quit();
return;
}
// System.out.println(" i = " + i );
try
{
// *** PongThread is a inner class in this file!! ***
new PongThread();
}
catch ( Exception e )
{
System.out.println("ERROR IN ping() " );
System.out.println("err: i = " + i );
System.out.println("err: " + e.getMessage());
e.printStackTrace();
// quit();
}
// System.out.println(" returned i = " + i );
}
public void
setPong ( PingTest1 pong )
{
this.pong = pong;
}
public void
quit ( )
{
Date endDate = new Date();
try
{
fw.write ( "interations = " + i + "\n" );
fw.write ( "" + endDate.getTime() + " - " +
startDate.getTime() + " = " +
(endDate.getTime() - startDate.getTime()) + "\n" );
fw.flush();
}
catch ( Exception e )
{
System.out.println(" ERROR IN quit() " );
System.out.println("err: " + e.getMessage());
e.printStackTrace();
}
// *** ExitThread is an inner class in this file **
new ExitThread();
}
/**********************************
PongThread
***********************************/
class PongThread extends Thread
{
public PongThread ()
{
this.start();
}
public void
run ()
{
try
{
pong.ping();
}
catch (Exception e)
{
System.out.println("PingTest1 err: i = " + i );
System.out.println("err: " + e.getMessage());
e.printStackTrace();
System.exit ( -1 );
}
}
}
/**********************************
ExitThread
***********************************/
class ExitThread extends Thread
{
public ExitThread () { this.start(); }
public void run () { System.exit ( -1 ); }
}
/**********************************
Main
***********************************/
public static void main ( String args[])
{
try
{
PingTest1 ping = new PingTest1( "ping.log", 20000 );
PingTest1 pong = new PingTest1( "pong.log", 20000 );
// Set them up to ping each other
pong.setPong ( ping );
ping.setPong ( pong );
// Set start times
pong.setStartDate ( );
ping.setStartDate ( );
// start the process
ping.ping( );
try
{
Thread.sleep( 1000 );
}
catch ( Exception e )
{
System.out.println(" ERROR IN main() " );
System.out.println("err: " + e.getMessage());
e.printStackTrace();
}
}
catch (Exception e)
{
System.out.println("Err: " + e.getMessage());
e.printStackTrace();
System.exit ( -1 );
}
}
}
file test.sh
date
echo timex java -native -mx140m PingTest1
timex java -native -mx140m PingTest1
date
echo timex java -green -mx140m PingTest1
timex java -green -mx140m PingTest1
date
echo timex java -native -mx140m PingTest1
timex java -native -mx140m PingTest1
date
echo timex java -green -mx140m PingTest1
timex java -green -mx140m PingTest1
date
echo timex java -native -mx140m PingTest1
timex java -native -mx140m PingTest1
date
echo timex java -green -mx140m PingTest1
timex java -green -mx140m PingTest1
(Review ID: 21841)
======================================================================
- duplicates
-
JDK-4089640 sync methods on multi-processor machines too slow
-
- Closed
-