Skip to content

Commit f451f57

Browse files
author
Tobias Hafner
committed
Improve analysis
1 parent 52b1f91 commit f451f57

6 files changed

Lines changed: 74 additions & 44 deletions

File tree

src/main/java/org/polypheny/simpleclient/scenario/EvaluationThread.java

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,15 @@ public EvaluationThread( Queue<QueryListEntry> queryList, Executor executor, Set
6767

6868
@Override
6969
public void run() {
70-
while (!queries.isEmpty() && !abort) {
70+
while ( !queries.isEmpty() && !abort ) {
7171
QueryListEntry queryListEntry = queries.poll();
72-
if (queryListEntry == null) {
72+
if ( queryListEntry == null ) {
7373
break;
7474
}
7575

76-
long measuredTime = executeAndMeasure(queryListEntry);
77-
recordMeasuredTime(queryListEntry, measuredTime);
76+
executeAndMeasure( queryListEntry );
7877

79-
if (commitAfterEveryQuery) {
78+
if ( commitAfterEveryQuery ) {
8079
commitSafely();
8180
}
8281
}
@@ -85,45 +84,45 @@ public void run() {
8584
executor.flushCsvWriter();
8685
}
8786

88-
protected long executeAndMeasure(QueryListEntry queryListEntry) {
87+
88+
protected void executeAndMeasure( QueryListEntry queryListEntry ) {
8989
long startTime = System.nanoTime();
9090
try {
91-
executor.executeQuery(queryListEntry.query);
92-
} catch (ExecutorException e) {
93-
log.error("Caught exception while executing queries", e);
94-
threadMonitor.notifyAboutError(e);
95-
rollbackSafely(e);
96-
throw new RuntimeException(e);
91+
executor.executeQuery( queryListEntry.query );
92+
} catch ( ExecutorException e ) {
93+
log.error( "Caught exception while executing queries", e );
94+
threadMonitor.notifyAboutError( e );
95+
rollbackSafely( e );
96+
throw new RuntimeException( e );
9797
}
98-
return System.nanoTime() - startTime;
99-
}
100-
101-
protected void recordMeasuredTime(QueryListEntry entry, long measuredTime) {
102-
measuredTimes.add(measuredTime);
103-
measuredTimePerQueryType.get(entry.templateId).add(measuredTime);
104-
for (Integer id : entry.templateIds) {
105-
if (!id.equals(entry.templateId)) {
106-
measuredTimePerQueryType.get(id).add(measuredTime);
98+
long measuredTime = System.nanoTime() - startTime;
99+
measuredTimes.add( measuredTime );
100+
measuredTimePerQueryType.get( queryListEntry.templateId ).add( measuredTime );
101+
for ( Integer id : queryListEntry.templateIds ) {
102+
if ( !id.equals( queryListEntry.templateId ) ) {
103+
measuredTimePerQueryType.get( id ).add( measuredTime );
107104
}
108105
}
109106
}
110107

108+
111109
protected void commitSafely() {
112110
try {
113111
executor.executeCommit();
114-
} catch (ExecutorException e) {
115-
log.error("Caught exception while committing", e);
116-
threadMonitor.notifyAboutError(e);
117-
rollbackSafely(e);
118-
throw new RuntimeException(e);
112+
} catch ( ExecutorException e ) {
113+
log.error( "Caught exception while committing", e );
114+
threadMonitor.notifyAboutError( e );
115+
rollbackSafely( e );
116+
throw new RuntimeException( e );
119117
}
120118
}
121119

122-
protected void rollbackSafely(Exception originalException) {
120+
121+
protected void rollbackSafely( Exception originalException ) {
123122
try {
124123
executor.executeRollback();
125-
} catch (ExecutorException rollbackException) {
126-
log.error("Error while rollback", originalException);
124+
} catch ( ExecutorException rollbackException ) {
125+
log.error( "Error while rollback", originalException );
127126
}
128127
}
129128

src/main/java/org/polypheny/simpleclient/scenario/Scenario.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ protected void calculateResults( Map<Integer, String> queryTypes, Properties pro
8181
long min = summaryStatistics.getMin();
8282
double stddev = calculateSampleStandardDeviation( time, mean );
8383

84-
properties.put( "queryTypes_" + templateId + "_mean", processDoubleValue( mean ) );
84+
properties.put( "queryTypes_" + templateId + "_mean [ms]", processDoubleValue( mean ) );
8585
if ( ChronosAgent.STORE_INDIVIDUAL_QUERY_TIMES ) {
86-
properties.put( "queryTypes_" + templateId + "_all", Joiner.on( ',' ).join( time ) );
86+
properties.put( "queryTypes_" + templateId + "_all [ms]", Joiner.on( ',' ).join( time ) );
8787
}
88-
properties.put( "queryTypes_" + templateId + "_stddev", processDoubleValue( stddev ) );
89-
properties.put( "queryTypes_" + templateId + "_min", min / 1_000_000L );
90-
properties.put( "queryTypes_" + templateId + "_max", max / 1_000_000L );
88+
properties.put( "queryTypes_" + templateId + "_stddev [ms]", processDoubleValue( stddev ) );
89+
properties.put( "queryTypes_" + templateId + "_min [ms]", min / 1_000_000L );
90+
properties.put( "queryTypes_" + templateId + "_max [ms]", max / 1_000_000L );
9191
} else {
92-
properties.put( "queryTypes_" + templateId + "_mean", 0 );
93-
properties.put( "queryTypes_" + templateId + "_stddev", 0 );
94-
properties.put( "queryTypes_" + templateId + "_min", 0 );
95-
properties.put( "queryTypes_" + templateId + "_max", 0 );
92+
properties.put( "queryTypes_" + templateId + "_mean [ms]", 0 );
93+
properties.put( "queryTypes_" + templateId + "_stddev [ms]", 0 );
94+
properties.put( "queryTypes_" + templateId + "_min [ms]", 0 );
95+
properties.put( "queryTypes_" + templateId + "_max [ms]", 0 );
9696
}
9797
properties.put( "queryTypes_" + templateId + "_example", queryTypes.get( templateId ) );
9898
}

src/main/java/org/polypheny/simpleclient/scenario/scalingBench/ErrorHandlingEvaluationThread.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,23 @@ public boolean isExpectedException( Throwable e ) {
5959

6060

6161
@Override
62-
protected long executeAndMeasure( QueryListEntry queryListEntry ) {
62+
protected void executeAndMeasure( QueryListEntry queryListEntry ) {
6363
long startTime = System.nanoTime();
6464
try {
6565
executor.executeQuery( queryListEntry.query );
66+
67+
long measuredTime = System.nanoTime() - startTime;
68+
measuredTimes.add( measuredTime );
69+
measuredTimePerQueryType.get( queryListEntry.templateId ).add( measuredTime );
70+
for ( Integer id : queryListEntry.templateIds ) {
71+
if ( !id.equals( queryListEntry.templateId ) ) {
72+
measuredTimePerQueryType.get( id ).add( measuredTime );
73+
}
74+
}
6675
} catch ( ExecutorException e ) {
6776
throwIfUnexpected( e, "executing queries", queryListEntry.query.getSql() );
6877
}
69-
return System.nanoTime() - startTime;
78+
7079
}
7180

7281

src/main/java/org/polypheny/simpleclient/scenario/scalingBench/ErrorHandlingPolyphenyScenario.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,18 @@ protected long commonExecuteWithExpectedErrors( List<QueryListEntry> queries, Pr
113113

114114
@Override
115115
public void analyze( Properties properties, File outputDirectory ) {
116-
super.analyze( properties, outputDirectory );
116+
properties.put( "executeRuntime [s]", executeRuntime / 1000000000.0 );
117+
properties.put( "measuredTime [ns]", calculateMean( measuredTimes ) );
118+
119+
properties.put( "numberOfQueries", measuredTimes.size() + failedQueries );
120+
properties.put( "numberOfSuccessfulQueries", measuredTimes.size() );
117121
properties.put( "numberOfFailedQueries", failedQueries );
118-
properties.put( "querySuccessRatio", (measuredTimes.size() - failedQueries) / measuredTimes.size());
122+
123+
properties.put( "throughput [succ.q/s]", measuredTimes.size() / (executeRuntime / 1000000000.0) );
124+
properties.put( "querySuccessRatio", measuredTimes.size() / (measuredTimes.size() + failedQueries));
125+
126+
measuredTimePerQueryType.forEach( ( templateId, time ) -> calculateResults( queryTypes, properties, templateId, time ) );
127+
properties.put( "queryTypes_maxId", queryTypes.size() );
119128
}
120129

121130

src/main/java/org/polypheny/simpleclient/scenario/scalingBench/LockingBench.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,22 @@ public synchronized void store( OutputStream out, String comments) throws IOExce
173173
}
174174
};
175175

176-
File analysisFile = new File(outputDirectory, "analysis.txt");
176+
String fileName = String.format(
177+
"analysis_S%d_N%d_E%d_R%f.txt",
178+
config.sessionCount,
179+
config.namespaceCount,
180+
config.entityCount,
181+
config.readWriteRatio);
182+
183+
File analysisFile = new File(outputDirectory, fileName);
177184
analyze(analysis, analysisFile);
178185

186+
analysis.put( "number_of_sessions", config.sessionCount );
187+
analysis.put( "number_of_namespaces", config.namespaceCount );
188+
analysis.put("number_of_entities_per_namespace", config.entityCount );
189+
analysis.put( "number_of_queries", config.numberOfQueries );
190+
analysis.put( "read_write_ratio", config.readWriteRatio );
191+
179192
try (FileOutputStream out = new FileOutputStream(analysisFile)) {
180193
analysis.store(out, "Analysis results");
181194
} catch (IOException e) {

src/main/resources/org/polypheny/simpleclient/scenario/scalingbench/scalingbench.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ maxBatchSize = 100
2727

2828
progressReportBase = 100
2929
numberOfWarmUpIterations = 4
30-
numberOfQueries = 1000
30+
numberOfQueries = 10000
3131

0 commit comments

Comments
 (0)