Skip to content

Commit 6a27f85

Browse files
authored
Merge pull request #2270 from ClickHouse/jmh_app
[perf] Jmh app
2 parents 861fd5b + 3b488b4 commit 6a27f85

29 files changed

+365
-371
lines changed

.github/workflows/benchmarks.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Benchmarks
2+
description: Runs minimal JMH benchmark
3+
4+
on:
5+
schedule:
6+
- cron: "55 15 * * *"
7+
workflow_dispatch:
8+
inputs:
9+
pr:
10+
description: "Pull request#"
11+
required: false
12+
13+
env:
14+
CHC_BRANCH: "main"
15+
CH_VERSION: "24.8"
16+
JAVA_VERSION: 17
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.number || github.sha }}
20+
cancel-in-progress: true
21+
22+
jobs:
23+
jmh:
24+
if: ${{ startsWith(github.repository, 'ClickHouse/') }}
25+
name: "Mininal JMH Benchmarks"
26+
runs-on: "ubuntu-latest"
27+
timeout-minutes: 20
28+
steps:
29+
- name: Check out Git repository
30+
uses: actions/checkout@v4
31+
with:
32+
ref: ${{ env.CHC_BRANCH }}
33+
- name: Check out PR
34+
run: |
35+
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 \
36+
origin pull/${{ github.event.inputs.pr }}/merge:merged-pr && git checkout merged-pr
37+
if: github.event.inputs.pr != ''
38+
- name: Install JDK and Maven
39+
uses: actions/setup-java@v4
40+
with:
41+
distribution: "temurin"
42+
java-version: ${{ env.JAVA_VERSION }}
43+
cache: "maven"
44+
- name: Build
45+
run: mvn --batch-mode --no-transfer-progress -Dj8 -DskipTests=true clean install
46+
- name: Prepare Dataset
47+
run: |
48+
cd ./performance &&
49+
mvn --batch-mode --no-transfer-progress clean compile exec:exec -Dexec.executable=java \
50+
-Dexec.args="-classpath %classpath com.clickhouse.benchmark.data.DataSetGenerator -input sample_dataset.sql -name default -rows 100000"
51+
- name: Run Benchmarks
52+
run: |
53+
cd ./performance &&
54+
mvn --batch-mode --no-transfer-progress clean compile exec:exec -Dexec.executable=java -Dexec.args="-classpath %classpath com.clickhouse.benchmark.BenchmarkRunner \
55+
-l 100000,10000 -m 3 -t 15 -b q,i -d file://default.csv"
56+
- name: Upload test results
57+
uses: actions/upload-artifact@v4
58+
if: success()
59+
with:
60+
name: result ${{ github.job }}
61+
path: |
62+
performance/jmh-results*

performance/README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
11

2+
## JMH Benchmarks
23

3-
## DataSetGenerator
4+
5+
### Dependencies
6+
7+
8+
9+
### How to Run
10+
11+
12+
#### Generating Dataset
413

514
```shell
6-
mvn exec:java -Dscope=test -Dexec.mainClass="com.clickhouse.benchmark.data.ClickHouseDataTypesShort" -input <table_fields.sql> -rows <number_of_rows>
15+
mvn compile exec:exec -Dexec.executable=java -Dexec.args="-classpath %classpath com.clickhouse.benchmark.data.DataSetGenerator \
16+
-input sample_dataset.sql -name default -rows 10"
717
```
818

19+
#### Running Benchmarks
20+
21+
With default settings :
22+
```shell
23+
mvn compile exec:exec
24+
```
925

10-
## Performance Test
11-
12-
with custom dataset
26+
With custom measurement iterations:
1327
```shell
14-
mvn test-compile exec:java -Dexec.classpathScope=test -Dexec.mainClass="com.clickhouse.benchmark.BenchmarkRunner" -Dexec.args="--dataset=file://dataset_1741150759025.csv"
28+
mvn compile exec:exec -Dexec.executable=java -Dexec.args="-classpath %classpath com.clickhouse.benchmark.BenchmarkRunner -m 3"
1529
```
1630

31+
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`)
34+
- "-m" - number of measurement iterations
35+
- "-t" - time in seconds per iteration
36+
- "-b" - benchmark mask coma separated. Ex.: `-b writer,reader,i`. Default : `-b i,q`
37+
- "all" - Run alpl benchmarks
38+
- "i" - InsertClient - insert operation benchmarks
39+
- "q" - QueryClient - query operation benchmarks
40+
- "ci" - ConcurrentInsertClient - concurrent version of insert benchmarks
41+
- "cq" - ConcurrentQueryClient - concurrent version of query benchmarks
42+
- "lz" - Compression - compression related benchmarks
43+
- "writer" - Serializer - serialization only logic benchmarks
44+
- "reader" - DeSerilalizer - deserialization only logic benchmarks
45+
- "mixed" - MixedWorkload
46+

performance/pom.xml

Lines changed: 58 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,51 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55

6-
<parent>
7-
<groupId>com.clickhouse</groupId>
8-
<artifactId>clickhouse-java</artifactId>
9-
<version>${revision}</version>
10-
</parent>
11-
12-
<artifactId>java-performance</artifactId>
6+
<artifactId>jmh-benchmark</artifactId>
7+
<groupId>clickhouse.com</groupId>
8+
<version>0.1-SNAPSHOT</version>
139
<packaging>jar</packaging>
1410

15-
<name>ClickHouse Java Performance Tests</name>
16-
<description>ClickHouse Java Performance Tests</description>
11+
<name>JMH Benchmark for Java Client</name>
12+
<description>JMH Benchmark for Java Client</description>
1713
<url>https://github.com/ClickHouse/clickhouse-java/tree/main/performance</url>
1814

1915
<properties>
2016
<apache.httpclient.version>5.3.1</apache.httpclient.version>
21-
<shade.base>${project.groupId}.shaded</shade.base>
17+
<slf4j.version>2.0.17</slf4j.version>
18+
<ch.jdbc.revision>0.8.2-SNAPSHOT</ch.jdbc.revision>
19+
<jmh.version>1.37</jmh.version>
20+
<testcontainers.version>1.20.6</testcontainers.version>
21+
22+
<antrun-plugin.version>3.1.0</antrun-plugin.version>
23+
<assembly-plugin.version>3.6.0</assembly-plugin.version>
24+
<clean-plugin.version>3.3.1</clean-plugin.version>
25+
<compiler-plugin.version>3.13.0</compiler-plugin.version>
26+
<deploy-plugin.version>3.1.1</deploy-plugin.version>
27+
<enforcer-plugin.version>3.3.0</enforcer-plugin.version>
28+
<exec-plugin.version>3.5.0</exec-plugin.version>
29+
<failsafe-plugin.version>3.1.2</failsafe-plugin.version>
30+
<flatten-plugin.version>1.2.7</flatten-plugin.version>
31+
<git-plugin.version>6.0.0</git-plugin.version>
32+
<gpg-plugin.version>3.1.0</gpg-plugin.version>
33+
<helper-plugin.version>3.4.0</helper-plugin.version>
34+
<jacoco-plugin.version>0.8.12</jacoco-plugin.version>
35+
<jar-plugin.version>3.3.0</jar-plugin.version>
36+
<javadoc-plugin.version>3.5.0</javadoc-plugin.version>
37+
<native-plugin.version>0.9.23</native-plugin.version>
38+
<os-plugin.version>1.7.1</os-plugin.version>
39+
<protobuf-plugin.version>0.6.1</protobuf-plugin.version>
40+
<shade-plugin.version>3.5.0</shade-plugin.version>
41+
<source-plugin.version>3.2.1</source-plugin.version>
42+
<staging-plugin.version>1.6.13</staging-plugin.version>
43+
<surefire-plugin.version>3.2.5</surefire-plugin.version>
44+
<toolchains-plugin.version>3.1.0</toolchains-plugin.version>
45+
<versions-plugin.version>2.16.0</versions-plugin.version>
46+
<resource-plugin.version>3.3.1</resource-plugin.version>
47+
48+
<jmh.measure-iter>10</jmh.measure-iter>
49+
<jmh.measure-time>10</jmh.measure-time>
50+
2251
</properties>
2352

2453
<dependencies>
@@ -42,63 +71,37 @@
4271
<artifactId>jmh-generator-annprocess</artifactId>
4372
<version>${jmh.version}</version>
4473
</dependency>
45-
<dependency>
46-
<groupId>org.testng</groupId>
47-
<artifactId>testng</artifactId>
48-
<version>${testng.version}</version>
49-
</dependency>
74+
75+
<!-- Performance Test Dependencies -->
76+
<!-- <dependency>-->
77+
<!-- <groupId>org.testcontainers</groupId>-->
78+
<!-- <artifactId>testcontainers</artifactId>-->
79+
<!-- <version>${testcontainers.version}</version>-->
80+
<!-- <scope>compile</scope>-->
81+
<!-- </dependency>-->
5082
<!-- https://mvnrepository.com/artifact/org.testcontainers/clickhouse -->
5183
<dependency>
5284
<groupId>org.testcontainers</groupId>
5385
<artifactId>clickhouse</artifactId>
5486
<version>${testcontainers.version}</version>
5587
</dependency>
5688

57-
58-
<!-- Performance Test Dependencies -->
89+
<!-- Contains both JDBC drivers and clients -->
5990
<dependency>
60-
<groupId>${project.parent.groupId}</groupId>
61-
<artifactId>clickhouse-client</artifactId>
62-
<version>${revision}</version>
63-
</dependency>
64-
<dependency>
65-
<groupId>${project.parent.groupId}</groupId>
66-
<artifactId>clickhouse-client</artifactId>
67-
<version>${revision}</version>
68-
<type>test-jar</type>
69-
</dependency>
70-
<dependency>
71-
<groupId>org.testcontainers</groupId>
72-
<artifactId>testcontainers</artifactId>
73-
<version>${testcontainers.version}</version>
74-
</dependency>
75-
<dependency>
76-
<groupId>${project.parent.groupId}</groupId>
77-
<artifactId>clickhouse-http-client</artifactId>
78-
<version>${revision}</version>
79-
</dependency>
80-
<dependency>
81-
<groupId>${project.parent.groupId}</groupId>
82-
<artifactId>client-v2</artifactId>
83-
<version>${revision}</version>
84-
</dependency>
85-
<dependency>
86-
<groupId>${project.parent.groupId}</groupId>
91+
<groupId>com.clickhouse</groupId>
8792
<artifactId>clickhouse-jdbc</artifactId>
88-
<version>${revision}</version>
89-
</dependency>
90-
<dependency>
91-
<groupId>${project.parent.groupId}</groupId>
92-
<artifactId>jdbc-v2</artifactId>
93-
<version>${revision}</version>
93+
<version>${ch.jdbc.revision}</version>
94+
<classifier>all</classifier>
9495
</dependency>
96+
9597
</dependencies>
9698

9799
<build>
98100
<plugins>
99101
<plugin>
100102
<groupId>org.apache.maven.plugins</groupId>
101103
<artifactId>maven-compiler-plugin</artifactId>
104+
<version>${compiler-plugin.version}</version>
102105
<configuration>
103106
<annotationProcessorPaths>
104107
<path>
@@ -115,26 +118,6 @@
115118
<release>11</release>
116119
</configuration>
117120
</plugin>
118-
<plugin>
119-
<groupId>org.apache.maven.plugins</groupId>
120-
<artifactId>maven-shade-plugin</artifactId>
121-
<executions>
122-
<execution>
123-
<phase>package</phase>
124-
<goals>
125-
<goal>shade</goal>
126-
</goals>
127-
<configuration>
128-
<finalName>benchmarks</finalName>
129-
<transformers>
130-
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
131-
<mainClass>com.clickhouse.benchmark.BenchmarkRunner</mainClass>
132-
</transformer>
133-
</transformers>
134-
</configuration>
135-
</execution>
136-
</executions>
137-
</plugin>
138121
<plugin>
139122
<groupId>org.codehaus.mojo</groupId>
140123
<artifactId>build-helper-maven-plugin</artifactId>
@@ -164,7 +147,7 @@
164147
</descriptorRefs>
165148
<archive>
166149
<manifest>
167-
<mainClass>com.clickhouse.benchmark.BenchmarkRunner</mainClass>
150+
<mainClass>com.clickhouse.com.clickhouse.benchmark.BenchmarkRunner</mainClass>
168151
</manifest>
169152
</archive>
170153
</configuration>
@@ -181,21 +164,21 @@
181164
<plugin>
182165
<groupId>org.codehaus.mojo</groupId>
183166
<artifactId>exec-maven-plugin</artifactId>
167+
<version>${exec-plugin.version}</version>
184168
<executions>
185169
<execution>
186170
<id>run-benchmarks</id>
187-
<phase>integration-test</phase>
188171
<goals>
189172
<goal>exec</goal>
190173
</goals>
191174
<configuration>
192-
<classpathScope>test</classpathScope>
193175
<executable>java</executable>
194176
<arguments>
195177
<argument>-classpath</argument>
196-
<classpath />
178+
<classpath/>
197179
<argument>com.clickhouse.benchmark.BenchmarkRunner</argument>
198-
<argument>.*</argument>
180+
<argument>-m ${jmh.measure-iter}</argument>
181+
<argument>-t ${jmh.measure-time}</argument>
199182
</arguments>
200183
</configuration>
201184
</execution>

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();

0 commit comments

Comments
 (0)