Skip to content

Commit 81afe97

Browse files
committed
added dataset generation
1 parent ee1745b commit 81afe97

File tree

5 files changed

+69
-10
lines changed

5 files changed

+69
-10
lines changed

.github/workflows/benchmarks.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ jobs:
5555
cache: "maven"
5656
- name: Build
5757
run: mvn --batch-mode --no-transfer-progress -Dj8 -DskipTests=true clean install
58-
- name: Build
58+
- name: Run Benchmarks
5959
run: |
60-
cd performance \
61-
mvn compile exec:exec -Dexec.args="-classpath %classpath com.clickhouse.benchmark.BenchmarkRunner -m 3 -t 30 -b i"
60+
cd performance;\
61+
mvn compile exec:exec -Dexec.args="-classpath %classpath com.clickhouse.benchmark.data.DataSetGenerator \
62+
-input sample_dataset.sql -name default -rows 100000"; \
63+
mvn compile exec:exec -Dexec.args="-classpath %classpath com.clickhouse.benchmark.BenchmarkRunner -l 100000,10000 -m 1 -t 3 -b i -d file://default.csv"
6264
- name: Upload test results
6365
uses: actions/upload-artifact@v4
6466
if: success()

performance/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88

99
### How to Run
1010

11+
12+
#### Generating Dataset
13+
14+
```shell
15+
mvn compile exec:exec -Dexec.args="-classpath %classpath com.clickhouse.benchmark.data.DataSetGenerator \
16+
-input sample_dataset.sql -name default -rows 10"
17+
```
18+
19+
#### Running Benchmarks
20+
1121
With default settings :
1222
```shell
1323
mvn compile exec:exec
@@ -19,6 +29,8 @@ mvn compile exec:exec -Dexec.args="-classpath %classpath com.clickhouse.benchmar
1929
```
2030

2131
Other options:
32+
- "-d" - dataset name or file path (like `file://default.csv`)
33+
- "-l" - dataset limits to test coma separated (ex.: `-l 10000,10000`)
2234
- "-m" - number of measurement iterations
2335
- "-t" - time in seconds per iteration
2436
- "-b" - benchmark mask coma separated. Ex.: `-b writer,reader,i`. Default : `-b i,q`

performance/sample_dataset.sql

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
CREATE TABLE big_columns_example
2+
(
3+
-- Float64 columns
4+
float_col_1 Float64,
5+
float_col_2 Float64,
6+
float_col_3 Float64,
7+
float_col_4 Float64,
8+
float_col_5 Float64,
9+
float_col_6 Float64,
10+
float_col_7 Float64,
11+
float_col_8 Float64,
12+
float_col_9 Float64,
13+
float_col_10 Float64,
14+
15+
-- String columns
16+
str_col_1 String,
17+
str_col_2 String,
18+
str_col_3 String,
19+
str_col_4 String,
20+
str_col_5 String,
21+
str_col_6 String,
22+
str_col_7 String,
23+
str_col_8 String,
24+
str_col_9 String,
25+
str_col_10 String,
26+
27+
-- Int64 columns
28+
int_col_1 Int64,
29+
int_col_2 Int64,
30+
int_col_3 Int64,
31+
int_col_4 Int64,
32+
int_col_5 Int64,
33+
int_col_6 Int64,
34+
int_col_7 Int64,
35+
int_col_8 Int64,
36+
int_col_9 Int64,
37+
int_col_10 Int64
38+
)
39+
ENGINE = MergeTree
40+
ORDER BY tuple();

performance/src/main/java/com/clickhouse/benchmark/BenchmarkRunner.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
import org.slf4j.Logger;
1313
import org.slf4j.LoggerFactory;
1414

15-
import java.util.HashMap;
16-
import java.util.Map;
17-
import java.util.SortedSet;
18-
import java.util.TreeSet;
15+
import java.util.*;
1916
import java.util.concurrent.TimeUnit;
2017

2118
import static com.clickhouse.benchmark.TestEnvironment.isCloud;
@@ -35,15 +32,21 @@ public static void main(String[] args) throws Exception {
3532
final int measurementTime = Integer.parseInt(options.getOrDefault("-t", "" + (isCloud() ? 30 : 10)));
3633
final String resultFile = String.format("jmh-results-%s-%s.json", env, time);
3734
final String outputFile = String.format("jmh-results-%s-%s.out", env, time);
35+
final String datasetName = options.getOrDefault("-d", "file://default.csv");
36+
final String[] limits = options.getOrDefault("-l", "300000,100000,10000").split(",");
3837

3938
System.out.println("Measurement iterations: " + measurementIterations);
4039
System.out.println("Measurement time: " + measurementTime + "s");
4140
System.out.println("Env: " + env);
41+
System.out.println("Dataset: " + datasetName);
42+
System.out.println("Limits: " + Arrays.asList(limits));
4243
System.out.println("Epoch Time: " + time);
4344

4445
ChainedOptionsBuilder optBuilder = new OptionsBuilder()
4546
.forks(1) // must be a fork. No fork only for debugging
4647
.mode(Mode.SampleTime)
48+
.param("datasetSourceName", datasetName)
49+
.param("limit", limits)
4750
.timeUnit(TimeUnit.MILLISECONDS)
4851
.addProfiler(GCProfiler.class)
4952
.addProfiler(MemPoolProfiler.class)
@@ -54,7 +57,8 @@ public static void main(String[] args) throws Exception {
5457
.measurementTime(TimeValue.seconds(measurementTime))
5558
.resultFormat(ResultFormatType.JSON)
5659
.output(outputFile)
57-
.result(resultFile);
60+
.result(resultFile)
61+
.shouldFailOnError(true);
5862

5963
String testMask = options.getOrDefault("-b", "q,i");
6064
String[] testMaskParts = testMask.split(",");

performance/src/main/java/com/clickhouse/benchmark/data/DataSetGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public static void main(String[] args) throws IOException {
5757
if (i + 1 < args.length) {
5858
datasetName = args[++i];
5959
}
60+
break;
6061
default:
6162
// Ignore unknown flags
6263
break;
@@ -93,7 +94,7 @@ public static void main(String[] args) throws IOException {
9394
LocalDateTime seriesStart = null;
9495
Duration seriesInterval = Duration.ofSeconds(1);
9596

96-
File outputFile = new File("dataset_" + System.currentTimeMillis() + ".csv");
97+
File outputFile = new File(datasetName + ".csv");
9798
try (BufferedWriter writer = Files.newBufferedWriter(outputFile.toPath())) {
9899
writer.write(datasetName + "\n");
99100
writer.write("--Create Table Statement\n");
@@ -125,7 +126,7 @@ private static List<Column> parseCreateTable(String sql) throws Exception {
125126
int columnCount = 0;
126127
for (String line : reader.lines().collect(Collectors.toList())) {
127128
line = line.trim();
128-
if (line.startsWith("CREATE TABLE") || line.startsWith("CREATE TEMPORARY TABLE")) {
129+
if (line.startsWith("CREATE TABLE") || line.startsWith("CREATE TEMPORARY TABLE") || line.trim().startsWith("--")) {
129130
continue; // Skip the CREATE TABLE line
130131
}
131132
if (line.startsWith(")")) {

0 commit comments

Comments
 (0)