Skip to content

Commit cdc7122

Browse files
authored
Merge pull request #2212 from ClickHouse/v2_async_compression
corrected v1 tests and config to match v2
2 parents 9ce899e + 073889c commit cdc7122

3 files changed

Lines changed: 48 additions & 6 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception {
3232
Options opt = new OptionsBuilder()
3333
.include(QueryClient.class.getSimpleName())
3434
.include(InsertClient.class.getSimpleName())
35-
.include(Components.class.getSimpleName())
35+
// .include(Components.class.getSimpleName())
3636
.forks(1) // must be a fork. No fork only for debugging
3737
.mode(Mode.SampleTime)
3838
.timeUnit(TimeUnit.MILLISECONDS)
@@ -45,6 +45,7 @@ public static void main(String[] args) throws Exception {
4545
.jvmArgs("-Xms8g", "-Xmx8g")
4646
.measurementTime(TimeValue.seconds(isCloud() ? 30 : 10))
4747
.resultFormat(ResultFormatType.JSON)
48+
.output(String.format("jmh-results-%s-%s.out", isCloud() ? "cloud" : "local", System.currentTimeMillis()))
4849
.result(String.format("jmh-results-%s-%s.json", isCloud() ? "cloud" : "local", System.currentTimeMillis()))
4950
.build();
5051

performance/src/test/com/clickhouse/benchmark/clients/BenchmarkBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.clickhouse.client.api.Client;
1313
import com.clickhouse.client.api.enums.Protocol;
1414
import com.clickhouse.client.api.insert.InsertResponse;
15+
import com.clickhouse.client.config.ClickHouseClientOption;
1516
import com.clickhouse.data.ClickHouseDataProcessor;
1617
import com.clickhouse.client.api.query.GenericRecord;
1718
import com.clickhouse.data.ClickHouseFormat;
@@ -77,11 +78,10 @@ public static class DataState {
7778
int limit;
7879
@Param({"data_filled"})
7980
String tableNameFilled;
81+
8082
@Param({"data_empty"})
8183
String tableNameEmpty;
8284

83-
@Param({"true"})
84-
boolean useClientCompression = true;
8585
DataSet dataSet;
8686

8787
public void setDataSet(DataSet dataSet) {

performance/src/test/com/clickhouse/benchmark/clients/InsertClient.java

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void insertV1(DataState dataState) {
5757
try (ClickHouseResponse response = clientV1.read(getServer())
5858
.write()
5959
.option(ClickHouseClientOption.ASYNC, false)
60-
.option(ClickHouseClientOption.COMPRESS, dataState.useClientCompression)
60+
.option(ClickHouseClientOption.DECOMPRESS, false)
6161
.format(format)
6262
.query(BenchmarkRunner.getInsertQuery(dataState.tableNameEmpty))
6363
.data(out -> {
@@ -81,7 +81,46 @@ public void insertV2(DataState dataState) {
8181
out.write(bytes);
8282
}
8383
out.close();
84-
}, format, new InsertSettings().compressClientRequest(dataState.useClientCompression)).get()) {
84+
}, format, new InsertSettings().compressClientRequest(false)).get()) {
85+
response.getWrittenRows();
86+
}
87+
} catch (Exception e) {
88+
LOGGER.error("Error: ", e);
89+
}
90+
}
91+
92+
@Benchmark
93+
public void insertV1Compressed(DataState dataState) {
94+
try {
95+
ClickHouseFormat format = dataState.dataSet.getFormat();
96+
try (ClickHouseResponse response = clientV1.read(getServer())
97+
.write()
98+
.option(ClickHouseClientOption.ASYNC, false)
99+
.option(ClickHouseClientOption.DECOMPRESS, true)
100+
.format(format)
101+
.query(BenchmarkRunner.getInsertQuery(dataState.tableNameEmpty))
102+
.data(out -> {
103+
for (byte[] bytes: dataState.dataSet.getBytesList(format)) {
104+
out.write(bytes);
105+
}
106+
}).executeAndWait()) {
107+
response.getSummary();
108+
}
109+
} catch (Exception e) {
110+
LOGGER.error("Error: ", e);
111+
}
112+
}
113+
114+
@Benchmark
115+
public void insertV2Compressed(DataState dataState) {
116+
try {
117+
ClickHouseFormat format = dataState.dataSet.getFormat();
118+
try (InsertResponse response = clientV2.insert(dataState.tableNameEmpty, out -> {
119+
for (byte[] bytes: dataState.dataSet.getBytesList(format)) {
120+
out.write(bytes);
121+
}
122+
out.close();
123+
}, format, new InsertSettings()).get()) {
85124
response.getWrittenRows();
86125
}
87126
} catch (Exception e) {
@@ -97,6 +136,7 @@ public void insertV1RowBinary(DataState dataState) {
97136
.write()
98137
.option(ClickHouseClientOption.ASYNC, false)
99138
.format(format)
139+
.option(ClickHouseClientOption.DECOMPRESS, false)
100140
.query(BenchmarkRunner.getInsertQuery(dataState.tableNameEmpty))
101141
.data(out -> {
102142
ClickHouseDataProcessor p = dataState.dataSet.getClickHouseDataProcessor();
@@ -131,7 +171,8 @@ public void insertV2RowBinary(DataState dataState) {
131171
}
132172
out.flush();
133173

134-
}, ClickHouseFormat.RowBinaryWithDefaults, new InsertSettings()).get()) {
174+
}, ClickHouseFormat.RowBinaryWithDefaults, new InsertSettings()
175+
.compressClientRequest(false)).get()) {
135176
response.getWrittenRows();
136177
}
137178
} catch (Exception e) {

0 commit comments

Comments
 (0)