Skip to content

Commit 073889c

Browse files
committed
added compressed insert as separate benchmark
1 parent ff98279 commit 073889c

3 files changed

Lines changed: 46 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 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)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,10 @@ public static class DataState {
7878
int limit;
7979
@Param({"data_filled"})
8080
String tableNameFilled;
81+
8182
@Param({"data_empty"})
8283
String tableNameEmpty;
8384

84-
@Param({"true"})
85-
boolean useClientCompression = true;
8685
DataSet dataSet;
8786

8887
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
@@ -42,7 +42,7 @@ public void insertV1(DataState dataState) {
4242
try (ClickHouseResponse response = clientV1.read(getServer())
4343
.write()
4444
.option(ClickHouseClientOption.ASYNC, false)
45-
.option(ClickHouseClientOption.DECOMPRESS, dataState.useClientCompression)
45+
.option(ClickHouseClientOption.DECOMPRESS, false)
4646
.format(format)
4747
.query(BenchmarkRunner.getInsertQuery(dataState.tableNameEmpty))
4848
.data(out -> {
@@ -66,7 +66,46 @@ public void insertV2(DataState dataState) {
6666
out.write(bytes);
6767
}
6868
out.close();
69-
}, format, new InsertSettings().compressClientRequest(dataState.useClientCompression)).get()) {
69+
}, format, new InsertSettings().compressClientRequest(false)).get()) {
70+
response.getWrittenRows();
71+
}
72+
} catch (Exception e) {
73+
LOGGER.error("Error: ", e);
74+
}
75+
}
76+
77+
@Benchmark
78+
public void insertV1Compressed(DataState dataState) {
79+
try {
80+
ClickHouseFormat format = dataState.dataSet.getFormat();
81+
try (ClickHouseResponse response = clientV1.read(getServer())
82+
.write()
83+
.option(ClickHouseClientOption.ASYNC, false)
84+
.option(ClickHouseClientOption.DECOMPRESS, true)
85+
.format(format)
86+
.query(BenchmarkRunner.getInsertQuery(dataState.tableNameEmpty))
87+
.data(out -> {
88+
for (byte[] bytes: dataState.dataSet.getBytesList(format)) {
89+
out.write(bytes);
90+
}
91+
}).executeAndWait()) {
92+
response.getSummary();
93+
}
94+
} catch (Exception e) {
95+
LOGGER.error("Error: ", e);
96+
}
97+
}
98+
99+
@Benchmark
100+
public void insertV2Compressed(DataState dataState) {
101+
try {
102+
ClickHouseFormat format = dataState.dataSet.getFormat();
103+
try (InsertResponse response = clientV2.insert(dataState.tableNameEmpty, out -> {
104+
for (byte[] bytes: dataState.dataSet.getBytesList(format)) {
105+
out.write(bytes);
106+
}
107+
out.close();
108+
}, format, new InsertSettings()).get()) {
70109
response.getWrittenRows();
71110
}
72111
} catch (Exception e) {
@@ -82,6 +121,7 @@ public void insertV1RowBinary(DataState dataState) {
82121
.write()
83122
.option(ClickHouseClientOption.ASYNC, false)
84123
.format(format)
124+
.option(ClickHouseClientOption.DECOMPRESS, false)
85125
.query(BenchmarkRunner.getInsertQuery(dataState.tableNameEmpty))
86126
.data(out -> {
87127
ClickHouseDataProcessor p = dataState.dataSet.getClickHouseDataProcessor();
@@ -116,7 +156,8 @@ public void insertV2RowBinary(DataState dataState) {
116156
}
117157
out.flush();
118158

119-
}, ClickHouseFormat.RowBinaryWithDefaults, new InsertSettings()).get()) {
159+
}, ClickHouseFormat.RowBinaryWithDefaults, new InsertSettings()
160+
.compressClientRequest(false)).get()) {
120161
response.getWrittenRows();
121162
}
122163
} catch (Exception e) {

0 commit comments

Comments
 (0)