Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit c4eb2d6291a5b0bdae439ce8dff30056768377af 1 parent c237d42
Chris Gioran authored
2  pom.xml
@@ -6,7 +6,7 @@
6 6 </parent>
7 7
8 8 <properties>
9   - <neo-version>1.3-SNAPSHOT</neo-version>
  9 + <neo-version>1.4-SNAPSHOT</neo-version>
10 10 <jvm-memory>768M</jvm-memory>
11 11 <run-main-class>Please supply it via argument</run-main-class>
12 12 <threshold/>
20 src/main/java/org/neo4j/bench/cases/mixedload/MixedLoadBenchCase.java
@@ -43,9 +43,6 @@
43 43 * The main driver for the operation performer threads. Keeps the probabilities
44 44 * with which each thread type is launched and aggregates the results of their
45 45 * runs.
46   - *
47   - * @author <a href=mailto:chris.gioran@neotechnology.com> Chris Gioran </a>
48   - *
49 46 */
50 47 public class MixedLoadBenchCase
51 48 {
@@ -159,6 +156,7 @@ else if ( dice > 0.1 )
159 156 e.printStackTrace();
160 157 }
161 158 }
  159 + service.shutdown();
162 160 try
163 161 {
164 162 getAll();
@@ -171,10 +169,9 @@ else if ( dice > 0.1 )
171 169 System.out.println( "Run for "
172 170 + ( System.currentTimeMillis() - startTime )
173 171 / 60000 + " minutes" );
174   - service.shutdown();
175 172 }
176   -
177   - private void printOutResults(String header)
  173 +
  174 + private void printOutResults( String header )
178 175 {
179 176 System.out.println( header );
180 177 System.out.println( "Total time (ms): " + totalTime );
@@ -218,17 +215,20 @@ private void gatherUp( List<Future<int[]>> tasks, WorkerType type,
218 215 / ( taskRes[2] == 0 ? 1 : taskRes[2] );
219 216 double thisWrites = taskRes[1]
220 217 / ( taskRes[2] == 0 ? 1 : taskRes[2] );
221   - // Sustained operations must be at least as long as half the average runtime
222   - if ( type == WorkerType.BULK && taskRes[2] > totalTime*0.5/tasksExecuted )
  218 + // Sustained operations must be at least as long as half the
  219 + // average runtime
  220 + if ( type == WorkerType.BULK
  221 + && taskRes[2] > totalTime * 0.5 / tasksExecuted )
223 222 {
224 223 if ( thisReads > sustainedReads )
225 224 sustainedReads = thisReads;
226 225 if ( thisWrites > sustainedWrites )
227 226 sustainedWrites = thisWrites;
228 227 }
229   - // The test run for more than 10% of the average time, long enough for
  228 + // The test run for more than 10% of the average time, long
  229 + // enough for
230 230 // getting a peak value
231   - if ( taskRes[2] > totalTime*0.1/tasksExecuted )
  231 + if ( taskRes[2] > totalTime * 0.1 / tasksExecuted )
232 232 {
233 233 if ( thisReads > peakReads ) peakReads = thisReads;
234 234 if ( thisWrites > peakWrites ) peakWrites = thisWrites;
7 src/main/java/org/neo4j/bench/cases/mixedload/Stats.java
@@ -22,9 +22,14 @@
22 22 import java.io.PrintStream;
23 23 import java.util.StringTokenizer;
24 24
  25 +/**
  26 + * In memory representation of a set of statistics from a bench run. Comparable
  27 + * with its kind for sorting purposes and performance degradation detection.
  28 + * Provides methods for reading in and writing out from/to file.
  29 + */
25 30 public class Stats implements Comparable<Stats>
26 31 {
27   - private String name;
  32 + private final String name;
28 33 private double avgReadsPerSec;
29 34 private double avgWritePerSec;
30 35 private double peakReadsPerSec;
5 src/main/java/org/neo4j/bench/cases/mixedload/workers/BulkCreateWorker.java
@@ -46,7 +46,8 @@
46 46 private int reads;
47 47 private int writes;
48 48
49   - public BulkCreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
  49 + public BulkCreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
  50 + int ops )
50 51 {
51 52 this.graphDb = graphDb;
52 53 this.nodes = nodes;
@@ -92,7 +93,7 @@ public BulkCreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int op
92 93 }
93 94 result[0] = reads;
94 95 result[1] = writes;
95   - result[2] = (int) (System.currentTimeMillis() - time);
  96 + result[2] = (int) ( System.currentTimeMillis() - time );
96 97 nodes.addAll( myNodes );
97 98 return result;
98 99 }
8 src/main/java/org/neo4j/bench/cases/mixedload/workers/BulkReaderWorker.java
@@ -45,7 +45,7 @@ public BulkReaderWorker( GraphDatabaseService graphDb )
45 45 public int[] call() throws Exception
46 46 {
47 47 long time = System.currentTimeMillis();
48   - for (int i = 0; i < 10; i++)
  48 + for ( int i = 0; i < 10; i++ )
49 49 {
50 50 for ( Node node : graphDb.getAllNodes() )
51 51 {
@@ -53,13 +53,13 @@ public BulkReaderWorker( GraphDatabaseService graphDb )
53 53 for ( Relationship r : node.getRelationships() )
54 54 {
55 55 reads += 1;
56   - for (String propertyKey : r.getPropertyKeys())
  56 + for ( String propertyKey : r.getPropertyKeys() )
57 57 {
58 58 r.getProperty( propertyKey );
59 59 reads += 2; // Prop key and prop value
60 60 }
61 61 }
62   - for (String propertyKey : node.getPropertyKeys())
  62 + for ( String propertyKey : node.getPropertyKeys() )
63 63 {
64 64 node.getProperty( propertyKey );
65 65 reads += 2; // Prop key and prop value
@@ -70,7 +70,7 @@ public BulkReaderWorker( GraphDatabaseService graphDb )
70 70 int[] result = new int[3];
71 71 result[0] = reads;
72 72 result[1] = writes;
73   - result[2] = (int) (System.currentTimeMillis() - time);
  73 + result[2] = (int) ( System.currentTimeMillis() - time );
74 74 return result;
75 75 }
76 76 }
5 src/main/java/org/neo4j/bench/cases/mixedload/workers/CreateWorker.java
@@ -44,7 +44,8 @@
44 44 private int reads;
45 45 private int writes;
46 46
47   - public CreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
  47 + public CreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
  48 + int ops )
48 49 {
49 50 this.graphDb = graphDb;
50 51 this.nodes = nodes;
@@ -87,7 +88,7 @@ public CreateWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
87 88 int[] result = new int[3];
88 89 result[0] = reads;
89 90 result[1] = writes;
90   - result[2] = (int) (System.currentTimeMillis() - time);
  91 + result[2] = (int) ( System.currentTimeMillis() - time );
91 92 return result;
92 93 }
93 94
2  src/main/java/org/neo4j/bench/cases/mixedload/workers/DeleteWorker.java
@@ -83,7 +83,7 @@ public DeleteWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
83 83 int[] result = new int[3];
84 84 result[0] = reads;
85 85 result[1] = writes;
86   - result[2] = (int) (System.currentTimeMillis() - time);
  86 + result[2] = (int) ( System.currentTimeMillis() - time );
87 87 return result;
88 88 }
89 89
18 src/main/java/org/neo4j/bench/cases/mixedload/workers/PropertyAddWorker.java
@@ -46,7 +46,8 @@
46 46 private int reads;
47 47 private int writes;
48 48
49   - public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int ops )
  49 + public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes,
  50 + int ops )
50 51 {
51 52 this.graphDb = graphDb;
52 53 this.nodes = nodes;
@@ -72,7 +73,7 @@ public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int o
72 73 }
73 74 else
74 75 {
75   -// addPropertyToRelationship();
  76 + // addPropertyToRelationship();
76 77 }
77 78 tx.success();
78 79 }
@@ -89,7 +90,7 @@ public PropertyAddWorker( GraphDatabaseService graphDb, Queue<Node> nodes, int o
89 90 int[] result = new int[3];
90 91 result[0] = reads;
91 92 result[1] = writes;
92   - result[2] = (int) (System.currentTimeMillis() - time);
  93 + result[2] = (int) ( System.currentTimeMillis() - time );
93 94 return result;
94 95 }
95 96
@@ -131,7 +132,7 @@ private void addPropertyToRelationship()
131 132 */
132 133 while ( offset-- > 0 || !temp.hasRelationship() )
133 134 {
134   - if (!temp.hasRelationship()) continue;
  135 + if ( !temp.hasRelationship() ) continue;
135 136 Relationship rel = temp.getRelationships().iterator().next();
136 137 if ( createNew && propToAdd == null
137 138 && rel.getPropertyKeys().iterator().hasNext() )
@@ -144,7 +145,7 @@ private void addPropertyToRelationship()
144 145 temp = nodes.remove();
145 146 }
146 147 // temp now holds a node that will do
147   - if (propToAdd == null)
  148 + if ( propToAdd == null )
148 149 {
149 150 propToAdd = getRandomPropertyName();
150 151 }
@@ -157,11 +158,12 @@ private void addPropertyToRelationship()
157 158 * exception. OK?
158 159 */
159 160 List<Relationship> thisNodesRels = new LinkedList<Relationship>();
160   - for (Relationship rel : temp.getRelationships())
  161 + for ( Relationship rel : temp.getRelationships() )
161 162 {
162 163 thisNodesRels.add( rel );
163 164 }
164   - thisNodesRels.get( r.nextInt(thisNodesRels.size()) ).setProperty( propToAdd, getRandomPropertyValue() );
  165 + thisNodesRels.get( r.nextInt( thisNodesRels.size() ) ).setProperty(
  166 + propToAdd, getRandomPropertyValue() );
165 167 }
166 168
167 169 private String getRandomPropertyName()
@@ -189,7 +191,7 @@ private Object getRandomPropertyValue()
189 191
190 192 private String getRandomString( int length )
191 193 {
192   - StringBuffer acc = new StringBuffer("");
  194 + StringBuffer acc = new StringBuffer( "" );
193 195 int i = 0;
194 196 while ( i++ < length )
195 197 {
16 src/main/java/org/neo4j/bench/chart/GenerateOpsPerSecChart.java
@@ -70,7 +70,7 @@ public boolean process() throws Exception
70 70 {
71 71 it.next();
72 72 }
73   - dataToDraw = data.tailSet( it.next() );
  73 + dataToDraw = data.tailSet( it.next() );
74 74 }
75 75 else
76 76 {
@@ -118,15 +118,19 @@ private void generateChart() throws Exception
118 118 private DefaultCategoryDataset generateDataset()
119 119 {
120 120 DefaultCategoryDataset dataset = new DefaultCategoryDataset();
121   -
  121 +
122 122 for ( Stats key : dataToDraw )
123 123 {
124 124 dataset.addValue( key.getAvgReadsPerSec(), "reads", key.getName() );
125 125 dataset.addValue( key.getAvgWritePerSec(), "writes", key.getName() );
126   - dataset.addValue( key.getPeakReadsPerSec()/100, "peak reads", key.getName() );
127   - dataset.addValue( key.getPeakWritesPerSec()/100, "peak writes", key.getName() );
128   - dataset.addValue( key.getSustainedReadsPerSec()/100, "sust reads", key.getName() );
129   - dataset.addValue( key.getSustainedWritesPerSec()/100, "sust writes", key.getName() );
  126 + dataset.addValue( key.getPeakReadsPerSec() / 100, "peak reads",
  127 + key.getName() );
  128 + dataset.addValue( key.getPeakWritesPerSec() / 100, "peak writes",
  129 + key.getName() );
  130 + dataset.addValue( key.getSustainedReadsPerSec() / 100,
  131 + "sust reads", key.getName() );
  132 + dataset.addValue( key.getSustainedWritesPerSec() / 100,
  133 + "sust writes", key.getName() );
130 134 }
131 135 return dataset;
132 136 }
29 src/main/java/org/neo4j/bench/regression/main/Main.java
@@ -23,29 +23,32 @@
23 23 import java.io.PrintStream;
24 24 import java.text.SimpleDateFormat;
25 25 import java.util.Date;
  26 +import java.util.HashMap;
  27 +import java.util.Map;
26 28
27 29 import org.neo4j.bench.cases.mixedload.MixedLoadBenchCase;
28 30 import org.neo4j.bench.cases.mixedload.Stats;
29 31 import org.neo4j.bench.chart.GenerateOpsPerSecChart;
30 32 import org.neo4j.graphdb.GraphDatabaseService;
31 33 import org.neo4j.helpers.Args;
  34 +import org.neo4j.kernel.Config;
32 35 import org.neo4j.kernel.EmbeddedGraphDatabase;
33 36
34   -import sun.misc.Signal;
35   -import sun.misc.SignalHandler;
36   -
37   -@SuppressWarnings( "restriction" )
  37 +/* @SuppressWarnings( "restriction" ) // for the signal */
38 38 public class Main
39 39 {
40 40 public static void main( String[] args ) throws Exception
41 41 {
42 42 Args argz = new Args( args );
43   - long timeToRun = Long.parseLong( argz.get( "time-to-run", "120" ) ); // Time
44   - // in
45   - // minutes
  43 + long timeToRun = Long.parseLong( argz.get( "time-to-run", "120" ) ); /* Time in minutes */
  44 + Map<String, String> props = new HashMap<String, String>();
  45 + props.put( Config.USE_MEMORY_MAPPED_BUFFERS, "true" );
46 46 final GraphDatabaseService db = new EmbeddedGraphDatabase( "db" );
47 47 final MixedLoadBenchCase myCase = new MixedLoadBenchCase( timeToRun );
48 48
  49 + /*
  50 + * Commented out because it breaks windows but it is nice to have for
  51 + * testing on real OSes
49 52 SignalHandler handler = new SignalHandler()
50 53 {
51 54 @Override
@@ -55,14 +58,14 @@ public void handle( Signal arg0 )
55 58 + myCase.getNodeQueue().size() );
56 59 }
57 60 };
58   - /*
59   - * SIGUSR1 is used by the JVM and INT, ABRT and friends
60   - * are all defined for specific usage by POSIX. While SIGINT
61   - * is conveniently issued by Ctrl-C, SIGUSR2 is for user defined
62   - * behavior so this is what I use.
63   - */
  61 + // SIGUSR1 is used by the JVM and INT, ABRT and friends
  62 + // are all defined for specific usage by POSIX. While SIGINT
  63 + // is conveniently issued by Ctrl-C, SIGUSR2 is for user defined
  64 + // behavior so this is what I use.
  65 +
64 66 Signal signal = new Signal( "USR2" );
65 67 Signal.handle( signal, handler );
  68 + */
66 69
67 70 myCase.run( db );
68 71 db.shutdown();

0 comments on commit c4eb2d6

Please sign in to comment.
Something went wrong with that request. Please try again.