Permalink
Browse files

Commented out the signal handler to leave it working on Windows

Updated the default kernel version under test to 1.4-SNAPSHOT
Lots of formatting
  • Loading branch information...
1 parent c237d42 commit c4eb2d6291a5b0bdae439ce8dff30056768377af @digitalstain committed Apr 27, 2011
View
2 pom.xml
@@ -6,7 +6,7 @@
</parent>
<properties>
- <neo-version>1.3-SNAPSHOT</neo-version>
+ <neo-version>1.4-SNAPSHOT</neo-version>
<jvm-memory>768M</jvm-memory>
<run-main-class>Please supply it via argument</run-main-class>
<threshold/>
View
20 src/main/java/org/neo4j/bench/cases/mixedload/MixedLoadBenchCase.java
@@ -43,9 +43,6 @@
* The main driver for the operation performer threads. Keeps the probabilities
* with which each thread type is launched and aggregates the results of their
* runs.
- *
- * @author <a href=mailto:chris.gioran@neotechnology.com> Chris Gioran </a>
- *
*/
public class MixedLoadBenchCase
{
@@ -159,6 +156,7 @@ else if ( dice > 0.1 )
e.printStackTrace();
}
}
+ service.shutdown();
try
{
getAll();
@@ -171,10 +169,9 @@ else if ( dice > 0.1 )
System.out.println( "Run for "
+ ( System.currentTimeMillis() - startTime )
/ 60000 + " minutes" );
- service.shutdown();
}
-
- private void printOutResults(String header)
+
+ private void printOutResults( String header )
{
System.out.println( header );
System.out.println( "Total time (ms): " + totalTime );
@@ -218,17 +215,20 @@ private void gatherUp( List<Future<int[]>> tasks, WorkerType type,
/ ( taskRes[2] == 0 ? 1 : taskRes[2] );
double thisWrites = taskRes[1]
/ ( taskRes[2] == 0 ? 1 : taskRes[2] );
- // Sustained operations must be at least as long as half the average runtime
- if ( type == WorkerType.BULK && taskRes[2] > totalTime*0.5/tasksExecuted )
+ // Sustained operations must be at least as long as half the
+ // average runtime
+ if ( type == WorkerType.BULK
+ && taskRes[2] > totalTime * 0.5 / tasksExecuted )
{
if ( thisReads > sustainedReads )
sustainedReads = thisReads;
if ( thisWrites > sustainedWrites )
sustainedWrites = thisWrites;
}
- // The test run for more than 10% of the average time, long enough for
+ // The test run for more than 10% of the average time, long
+ // enough for
// getting a peak value
- if ( taskRes[2] > totalTime*0.1/tasksExecuted )
+ if ( taskRes[2] > totalTime * 0.1 / tasksExecuted )
{
if ( thisReads > peakReads ) peakReads = thisReads;
if ( thisWrites > peakWrites ) peakWrites = thisWrites;
View
7 src/main/java/org/neo4j/bench/cases/mixedload/Stats.java
@@ -22,9 +22,14 @@
import java.io.PrintStream;
import java.util.StringTokenizer;
+/**
+ * In memory representation of a set of statistics from a bench run. Comparable
+ * with its kind for sorting purposes and performance degradation detection.
+ * Provides methods for reading in and writing out from/to file.
+ */
public class Stats implements Comparable<Stats>
{
- private String name;
+ private final String name;
private double avgReadsPerSec;
private double avgWritePerSec;
private double peakReadsPerSec;
View
5 src/main/java/org/neo4j/bench/cases/mixedload/workers/BulkCreateWorker.java
@@ -46,7 +46,8 @@
private int reads;
private int writes;
- public BulkCreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
+ public BulkCreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
+ int ops )
{
this.graphDb = graphDb;
this.nodes = nodes;
@@ -92,7 +93,7 @@ public BulkCreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int op
}
result[0] = reads;
result[1] = writes;
- result[2] = (int) (System.currentTimeMillis() - time);
+ result[2] = (int) ( System.currentTimeMillis() - time );
nodes.addAll( myNodes );
return result;
}
View
8 src/main/java/org/neo4j/bench/cases/mixedload/workers/BulkReaderWorker.java
@@ -45,21 +45,21 @@ public BulkReaderWorker( GraphDatabaseService graphDb )
public int[] call() throws Exception
{
long time = System.currentTimeMillis();
- for (int i = 0; i < 10; i++)
+ for ( int i = 0; i < 10; i++ )
{
for ( Node node : graphDb.getAllNodes() )
{
reads += 1;
for ( Relationship r : node.getRelationships() )
{
reads += 1;
- for (String propertyKey : r.getPropertyKeys())
+ for ( String propertyKey : r.getPropertyKeys() )
{
r.getProperty( propertyKey );
reads += 2; // Prop key and prop value
}
}
- for (String propertyKey : node.getPropertyKeys())
+ for ( String propertyKey : node.getPropertyKeys() )
{
node.getProperty( propertyKey );
reads += 2; // Prop key and prop value
@@ -70,7 +70,7 @@ public BulkReaderWorker( GraphDatabaseService graphDb )
int[] result = new int[3];
result[0] = reads;
result[1] = writes;
- result[2] = (int) (System.currentTimeMillis() - time);
+ result[2] = (int) ( System.currentTimeMillis() - time );
return result;
}
}
View
5 src/main/java/org/neo4j/bench/cases/mixedload/workers/CreateWorker.java
@@ -44,7 +44,8 @@
private int reads;
private int writes;
- public CreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
+ public CreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
+ int ops )
{
this.graphDb = graphDb;
this.nodes = nodes;
@@ -87,7 +88,7 @@ public CreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
int[] result = new int[3];
result[0] = reads;
result[1] = writes;
- result[2] = (int) (System.currentTimeMillis() - time);
+ result[2] = (int) ( System.currentTimeMillis() - time );
return result;
}
View
2 src/main/java/org/neo4j/bench/cases/mixedload/workers/DeleteWorker.java
@@ -83,7 +83,7 @@ public DeleteWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
int[] result = new int[3];
result[0] = reads;
result[1] = writes;
- result[2] = (int) (System.currentTimeMillis() - time);
+ result[2] = (int) ( System.currentTimeMillis() - time );
return result;
}
View
18 src/main/java/org/neo4j/bench/cases/mixedload/workers/PropertyAddWorker.java
@@ -46,7 +46,8 @@
private int reads;
private int writes;
- public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
+ public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
+ int ops )
{
this.graphDb = graphDb;
this.nodes = nodes;
@@ -72,7 +73,7 @@ public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int o
}
else
{
-// addPropertyToRelationship();
+ // addPropertyToRelationship();
}
tx.success();
}
@@ -89,7 +90,7 @@ public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int o
int[] result = new int[3];
result[0] = reads;
result[1] = writes;
- result[2] = (int) (System.currentTimeMillis() - time);
+ result[2] = (int) ( System.currentTimeMillis() - time );
return result;
}
@@ -131,7 +132,7 @@ private void addPropertyToRelationship()
*/
while ( offset-- > 0 || !temp.hasRelationship() )
{
- if (!temp.hasRelationship()) continue;
+ if ( !temp.hasRelationship() ) continue;
Relationship rel = temp.getRelationships().iterator().next();
if ( createNew && propToAdd == null
&& rel.getPropertyKeys().iterator().hasNext() )
@@ -144,7 +145,7 @@ private void addPropertyToRelationship()
temp = nodes.remove();
}
// temp now holds a node that will do
- if (propToAdd == null)
+ if ( propToAdd == null )
{
propToAdd = getRandomPropertyName();
}
@@ -157,11 +158,12 @@ private void addPropertyToRelationship()
* exception. OK?
*/
List<Relationship> thisNodesRels = new LinkedList<Relationship>();
- for (Relationship rel : temp.getRelationships())
+ for ( Relationship rel : temp.getRelationships() )
{
thisNodesRels.add( rel );
}
- thisNodesRels.get( r.nextInt(thisNodesRels.size()) ).setProperty( propToAdd, getRandomPropertyValue() );
+ thisNodesRels.get( r.nextInt( thisNodesRels.size() ) ).setProperty(
+ propToAdd, getRandomPropertyValue() );
}
private String getRandomPropertyName()
@@ -189,7 +191,7 @@ private Object getRandomPropertyValue()
private String getRandomString( int length )
{
- StringBuffer acc = new StringBuffer("");
+ StringBuffer acc = new StringBuffer( "" );
int i = 0;
while ( i++ < length )
{
View
16 src/main/java/org/neo4j/bench/chart/GenerateOpsPerSecChart.java
@@ -70,7 +70,7 @@ public boolean process() throws Exception
{
it.next();
}
- dataToDraw = data.tailSet( it.next() );
+ dataToDraw = data.tailSet( it.next() );
}
else
{
@@ -118,15 +118,19 @@ private void generateChart() throws Exception
private DefaultCategoryDataset generateDataset()
{
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
-
+
for ( Stats key : dataToDraw )
{
dataset.addValue( key.getAvgReadsPerSec(), "reads", key.getName() );
dataset.addValue( key.getAvgWritePerSec(), "writes", key.getName() );
- dataset.addValue( key.getPeakReadsPerSec()/100, "peak reads", key.getName() );
- dataset.addValue( key.getPeakWritesPerSec()/100, "peak writes", key.getName() );
- dataset.addValue( key.getSustainedReadsPerSec()/100, "sust reads", key.getName() );
- dataset.addValue( key.getSustainedWritesPerSec()/100, "sust writes", key.getName() );
+ dataset.addValue( key.getPeakReadsPerSec() / 100, "peak reads",
+ key.getName() );
+ dataset.addValue( key.getPeakWritesPerSec() / 100, "peak writes",
+ key.getName() );
+ dataset.addValue( key.getSustainedReadsPerSec() / 100,
+ "sust reads", key.getName() );
+ dataset.addValue( key.getSustainedWritesPerSec() / 100,
+ "sust writes", key.getName() );
}
return dataset;
}
View
29 src/main/java/org/neo4j/bench/regression/main/Main.java
@@ -23,29 +23,32 @@
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import org.neo4j.bench.cases.mixedload.MixedLoadBenchCase;
import org.neo4j.bench.cases.mixedload.Stats;
import org.neo4j.bench.chart.GenerateOpsPerSecChart;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.helpers.Args;
+import org.neo4j.kernel.Config;
import org.neo4j.kernel.EmbeddedGraphDatabase;
-import sun.misc.Signal;
-import sun.misc.SignalHandler;
-
-@SuppressWarnings( "restriction" )
+/* @SuppressWarnings( "restriction" ) // for the signal */
public class Main
{
public static void main( String[] args ) throws Exception
{
Args argz = new Args( args );
- long timeToRun = Long.parseLong( argz.get( "time-to-run", "120" ) ); // Time
- // in
- // minutes
+ long timeToRun = Long.parseLong( argz.get( "time-to-run", "120" ) ); /* Time in minutes */
+ Map<String, String> props = new HashMap<String, String>();
+ props.put( Config.USE_MEMORY_MAPPED_BUFFERS, "true" );
final GraphDatabaseService db = new EmbeddedGraphDatabase( "db" );
final MixedLoadBenchCase myCase = new MixedLoadBenchCase( timeToRun );
+ /*
+ * Commented out because it breaks windows but it is nice to have for
+ * testing on real OSes
SignalHandler handler = new SignalHandler()
{
@Override
@@ -55,14 +58,14 @@ public void handle( Signal arg0 )
+ myCase.getNodeQueue().size() );
}
};
- /*
- * SIGUSR1 is used by the JVM and INT, ABRT and friends
- * are all defined for specific usage by POSIX. While SIGINT
- * is conveniently issued by Ctrl-C, SIGUSR2 is for user defined
- * behavior so this is what I use.
- */
+ // SIGUSR1 is used by the JVM and INT, ABRT and friends
+ // are all defined for specific usage by POSIX. While SIGINT
+ // is conveniently issued by Ctrl-C, SIGUSR2 is for user defined
+ // behavior so this is what I use.
+
Signal signal = new Signal( "USR2" );
Signal.handle( signal, handler );
+ */
myCase.run( db );
db.shutdown();

0 comments on commit c4eb2d6

Please sign in to comment.