Skip to content

Commit ecd78da

Browse files
marcdumais-workMatthewKhouzam
authored andcommitted
[tests] update benchmark tests, config
The benchmarks were showing slow results for AsyncFileHandler,much slower compared to what they were until v0.4.0. The reason is that a couple of bugs were recently fixed in that handler, that resulted in the following configurable property, used for the benchmark tests, to not have the desired effect: org.eclipse.tracecompass.traceeventlogger.AsyncFileHandler.maxSize = 1000 After the bugs were fixed, AsyncFileHandler started to correctly use "maxSize" as the size of its record buffer. However, a buffer of 1000 is not enough for the logging load generated by the benchmark tests, making the new async handler look bad. Setting "bufferSize" to value 100k makes it big enough to "absorb" the logging load of the benchmark tests well, and brings back the previous level of performance for the async handler, such that the benchmark results are comparable to those from until v0.4.0. To detect such a problem in the future, the benchmark tests now compute the relative performance of the async file handler vs the old sync handler and fails the test if the former is not performing above a certain threshold. The threshold may need to be lowered a bit if e.g. it's not met once in a while during CI (there is variation in the results) In the benchmark results printed on STDOUT, the relative performance of the async file handlers now displayed as an extra column in the benchmark result tables. Also, the benchmark results are now printed in two versions: one un- formatted in "csv" format that's suitable to import e.g. in LibreOffice Calc, and another that's formatted for human readability. Signed-off-by: Marc Dumais <[email protected]>
1 parent 5d2850f commit ecd78da

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

src/test/java/org/eclipse/tracecompass/traceeventlogger/TestLoggerBenchmark.java

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package org.eclipse.tracecompass.traceeventlogger;
2626

2727
import static org.junit.Assert.fail;
28+
import static org.junit.Assert.assertTrue;
2829

2930
import java.io.File;
3031
import java.io.FileInputStream;
@@ -59,6 +60,7 @@ public class TestLoggerBenchmark {
5960
private long warmUp = 2000;
6061
private long maxRuns = warmUp * 100;
6162
private double growth = 2.3;
63+
private final static float newAsyncPerformenceThreshold = 2.5f;
6264

6365
/**
6466
* Benchmark events with fields
@@ -86,6 +88,7 @@ public String format(LogRecord record) {
8688
fLogger.addHandler(oldFileHandler);
8789
fLogger.setLevel(Level.ALL);
8890
Logger logger = fLogger;
91+
List<Float> asyncNewVsSyncOld = new ArrayList<>();
8992
List<Long> asyncNew = new ArrayList<>();
9093
List<Long> asyncOld = new ArrayList<>();
9194
List<Long> syncNew = new ArrayList<>();
@@ -212,10 +215,27 @@ public String format(LogRecord record) {
212215
long end2 = System.nanoTime();
213216
asyncOld.add(end2 - start2);
214217
}
215-
System.out.println("Runs,SyncOld,SyncNew,AsyncOld,AsyncNew"); //$NON-NLS-1$
218+
System.out.println("\n\"Regular\" Benchmark Results (csv):"); //$NON-NLS-1$
219+
System.out.println("Runs(#),SyncOld(ns),SyncNew(ns),AsyncOld(ns),AsyncNew(ns),AsyncNewVsSyncOld(rel perf)"); //$NON-NLS-1$
216220
for (int i = 0; i < run.size(); i++) {
217-
System.out.println(String.format("%d,%d,%d,%d,%d", run.get(i), syncOld.get(i), syncNew.get(i), //$NON-NLS-1$
218-
asyncOld.get(i), asyncNew.get(i)));
221+
float factor = (float)syncOld.get(i) / (float)asyncNew.get(i);
222+
asyncNewVsSyncOld.add(factor);
223+
System.out.println(String.format("%d,%d,%d,%d,%d,%.2f", run.get(i), syncOld.get(i), syncNew.get(i), //$NON-NLS-1$
224+
asyncOld.get(i), asyncNew.get(i), factor));
225+
}
226+
System.out.println("\n\"Regular\" Benchmark Results (Human-readable):"); //$NON-NLS-1$
227+
System.out.println("Runs(#) SyncOld(ms) SyncNew(ms) AsyncOld(ms) AsyncNew(ms) AsyncNewVsSyncOld(rel perf)"); //$NON-NLS-1$
228+
for (int i = 0; i < run.size(); i++) {
229+
float factor = asyncNewVsSyncOld.get(i);
230+
System.out.println(String.format("%7d %13.2f %13.2f %13.2f %13.2f %27.2fx", run.get(i), syncOld.get(i)*0.000001, syncNew.get(i)*0.000001, //$NON-NLS-1$
231+
asyncOld.get(i)*0.000001, asyncNew.get(i)*0.000001, factor));
232+
}
233+
234+
for (int i = 0; i < run.size(); i++) {
235+
float factor = asyncNewVsSyncOld.get(i);
236+
assertTrue("Runs: " + run.get(i) + " - AsyncNew expected to be much faster vs SyncOld! " + //$NON-NLS-1$//$NON-NLS-2$
237+
"Expected factor: > " + newAsyncPerformenceThreshold + "x, Actual: " + factor, //$NON-NLS-1$ //$NON-NLS-2$
238+
(factor > newAsyncPerformenceThreshold));
219239
}
220240
}
221241

@@ -279,6 +299,7 @@ public void testLeanBench() throws SecurityException, IOException {
279299
fLogger.addHandler(oldFileHandler);
280300
fLogger.setLevel(Level.ALL);
281301
Logger logger = fLogger;
302+
List<Float> asyncNewVsSyncOld = new ArrayList<>();
282303
List<Long> asyncNew = new ArrayList<>();
283304
List<Long> asyncOld = new ArrayList<>();
284305
List<Long> syncNew = new ArrayList<>();
@@ -390,10 +411,28 @@ public void testLeanBench() throws SecurityException, IOException {
390411
long end2 = System.nanoTime();
391412
asyncOld.add(end2 - start2);
392413
}
393-
System.out.println("Runs,SyncOldLean,SyncNewLean,AsyncOldLean,AsyncNewLean"); //$NON-NLS-1$
414+
System.out.println("\n\"Lean\" Benchmark Results (csv):"); //$NON-NLS-1$
415+
System.out.println("Runs(#),SyncOld(ns),SyncNew(ns),AsyncOld(ns),AsyncNew(ns),AsyncNewVsSyncOld(rel perf)"); //$NON-NLS-1$
416+
for (int i = 0; i < run.size(); i++) {
417+
float factor = (float)syncOld.get(i) / (float)asyncNew.get(i);
418+
asyncNewVsSyncOld.add(factor);
419+
System.out.println(String.format("%d,%d,%d,%d,%d,%.2f", run.get(i), syncOld.get(i), syncNew.get(i), //$NON-NLS-1$
420+
asyncOld.get(i), asyncNew.get(i), factor));
421+
}
422+
System.out.println("\n\"Lean\" Benchmark Results (Human-readable):"); //$NON-NLS-1$
423+
System.out.println("Runs(#) SyncOld(ms) SyncNew(ms) AsyncOld(ms) AsyncNew(ms) AsyncNewVsSyncOld(rel perf)"); //$NON-NLS-1$
424+
for (int i = 0; i < run.size(); i++) {
425+
float factor = asyncNewVsSyncOld.get(i);
426+
asyncNewVsSyncOld.add(factor);
427+
System.out.println(String.format("%7d %13.2f %13.2f %13.2f %13.2f %27.2fx", run.get(i), syncOld.get(i)*0.000001, syncNew.get(i)*0.000001, //$NON-NLS-1$
428+
asyncOld.get(i)*0.000001, asyncNew.get(i)*0.000001, factor));
429+
}
430+
System.out.println("-----\n"); //$NON-NLS-1$
394431
for (int i = 0; i < run.size(); i++) {
395-
System.out.println(String.format("%d,%d,%d,%d,%d", run.get(i), syncOld.get(i), syncNew.get(i), //$NON-NLS-1$
396-
asyncOld.get(i), asyncNew.get(i)));
432+
float factor = asyncNewVsSyncOld.get(i);
433+
assertTrue("Runs: " + run.get(i) + " - AsyncNewLean expected to be much faster vs SyncOldLean! " + //$NON-NLS-1$ //$NON-NLS-2$
434+
"Expected factor: > " + newAsyncPerformenceThreshold + "x, Actual: " + factor, //$NON-NLS-1$ //$NON-NLS-2$
435+
(factor > newAsyncPerformenceThreshold));
397436
}
398437
}
399438

src/test/java/org/eclipse/tracecompass/traceeventlogger/res/benchmarklogging.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
# used in Benchmarks
2626

27-
org.eclipse.tracecompass.traceeventlogger.AsyncFileHandler.maxSize = 1000
27+
org.eclipse.tracecompass.traceeventlogger.AsyncFileHandler.maxSize = 100000
2828
org.eclipse.tracecompass.traceeventlogger.AsyncFileHandler.queueDepth = 100
2929
org.eclipse.tracecompass.traceeventlogger.AsyncFileHandler.flushRate = 100

0 commit comments

Comments
 (0)