Skip to content

Commit 1fbd2c5

Browse files
committed
test: GH-5715 add denormalized theme benchmark queries
1 parent 5a2b638 commit 1fbd2c5

9 files changed

Lines changed: 610 additions & 50 deletions

File tree

core/sail/lmdb/src/test/java/org/eclipse/rdf4j/sail/lmdb/benchmark/ThemeQueryBenchmark.java

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.eclipse.rdf4j.benchmark.rio.util.ThemeDataSetGenerator;
3030
import org.eclipse.rdf4j.benchmark.rio.util.ThemeDataSetGenerator.Theme;
3131
import org.eclipse.rdf4j.common.transaction.IsolationLevels;
32+
import org.eclipse.rdf4j.query.TupleQuery;
3233
import org.eclipse.rdf4j.query.explanation.Explanation;
3334
import org.eclipse.rdf4j.queryrender.sparql.TupleExprIRRenderer;
3435
import org.eclipse.rdf4j.repository.sail.SailRepository;
@@ -53,12 +54,13 @@
5354
import org.openjdk.jmh.runner.Runner;
5455
import org.openjdk.jmh.runner.RunnerException;
5556
import org.openjdk.jmh.runner.options.OptionsBuilder;
57+
import org.openjdk.jmh.runner.options.TimeValue;
5658

5759
@State(Scope.Benchmark)
58-
@Warmup(iterations = 1, batchSize = 1, timeUnit = TimeUnit.SECONDS, time = 30)
60+
@Warmup(iterations = 10, batchSize = 1, timeUnit = TimeUnit.SECONDS, time = 1)
5961
@BenchmarkMode({ Mode.AverageTime })
6062
@Fork(value = 1, jvmArgs = { "-Xms32G", "-Xmx32G" })
61-
@Measurement(iterations = 1, batchSize = 1, timeUnit = TimeUnit.SECONDS, time = 10)
63+
@Measurement(iterations = 10, batchSize = 1, timeUnit = TimeUnit.SECONDS, time = 1)
6264
@OutputTimeUnit(TimeUnit.MILLISECONDS)
6365
public class ThemeQueryBenchmark {
6466

@@ -72,18 +74,20 @@ public class ThemeQueryBenchmark {
7274
private static final long EXPECTED_TRIPLES_DATA_SIZE_BYTES = 1500921856L;
7375
private static final long EXPECTED_VALUES_DATA_SIZE_BYTES = 713687040L;
7476

75-
@Param({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" })
77+
@Param({
78+
// "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
79+
"11", "12" })
7680
public int z_queryIndex;
7781

7882
@Param({
7983
"MEDICAL_RECORDS",
80-
"SOCIAL_MEDIA",
81-
"LIBRARY",
82-
"ENGINEERING",
83-
"HIGHLY_CONNECTED",
84-
"TRAIN",
85-
"ELECTRICAL_GRID",
86-
"PHARMA"
84+
// "SOCIAL_MEDIA",
85+
// "LIBRARY",
86+
// "ENGINEERING",
87+
// "HIGHLY_CONNECTED",
88+
// "TRAIN",
89+
// "ELECTRICAL_GRID",
90+
// "PHARMA"
8791
})
8892
public String themeName;
8993

@@ -97,7 +101,11 @@ public class ThemeQueryBenchmark {
97101
public static void main(String[] args) throws RunnerException {
98102
var opt = new OptionsBuilder()
99103
.include("ThemeQueryBenchmark")
100-
.forks(1)
104+
.forks(0)
105+
.measurementTime(TimeValue.milliseconds(1000))
106+
.measurementIterations(10)
107+
.measurementBatchSize(1)
108+
.warmupIterations(0)
101109
.build();
102110
new Runner(opt).run();
103111
}
@@ -119,6 +127,26 @@ public void setup() throws IOException {
119127
}
120128
}
121129

130+
@Benchmark
131+
public long executeQuery() {
132+
try (var connection = repository.getConnection()) {
133+
long count;
134+
TupleQuery tupleQuery = connection.prepareTupleQuery(query);
135+
tupleQuery.setMaxExecutionTime(10);
136+
try (var evaluate = tupleQuery.evaluate()) {
137+
count = evaluate
138+
.stream()
139+
.count();
140+
}
141+
142+
if (count != expected) {
143+
throw new IllegalStateException("Unexpected count: expected " + expected + " but got " + count);
144+
}
145+
146+
return count;
147+
}
148+
}
149+
122150
private void ensureDataLoadedAndValidated() throws IOException {
123151
var expectedDbFileSizes = readExpectedDbFileSizes();
124152
if (!hasExpectedDbFileSizes(expectedDbFileSizes)) {
@@ -285,24 +313,6 @@ public void tearDown() {
285313
storeConfig = null;
286314
}
287315

288-
@Benchmark
289-
public long executeQuery() {
290-
try (var connection = repository.getConnection()) {
291-
long count;
292-
try (var evaluate = connection.prepareTupleQuery(query).evaluate()) {
293-
count = evaluate
294-
.stream()
295-
.count();
296-
}
297-
298-
if (count != expected) {
299-
throw new IllegalStateException("Unexpected count: expected " + expected + " but got " + count);
300-
}
301-
302-
return count;
303-
}
304-
}
305-
306316
@Test
307317
@Disabled
308318
public void testQueryCounts() throws IOException {
@@ -346,6 +356,7 @@ public void setupVerifiesExpectedDbFileSizesInFixedStore() throws IOException {
346356
}
347357

348358
@Test
359+
@Disabled
349360
public void executeQueryReturnsExpectedCountForPharmaQueryTenAfterFreshGeneration() throws IOException {
350361
FileUtils.deleteDirectory(STORE_DIRECTORY);
351362
themeName = "PHARMA";

core/sail/memory/src/test/java/org/eclipse/rdf4j/sail/memory/benchmark/ThemeQueryBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class ThemeQueryBenchmark {
6262

6363
private static final String STORE_NAME = "memory";
6464

65-
@Param({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" })
65+
@Param({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" })
6666
public int z_queryIndex;
6767

6868
@Param({

core/sail/nativerdf/src/test/java/org/eclipse/rdf4j/sail/nativerdf/benchmark/ThemeQueryBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
@OutputTimeUnit(TimeUnit.MILLISECONDS)
5757
public class ThemeQueryBenchmark {
5858

59-
@Param({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" })
59+
@Param({ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" })
6060
public int z_queryIndex;
6161

6262
@Param({

0 commit comments

Comments
 (0)