Skip to content

Compression benchmarking (WIP) #2250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clickhouse-http-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<includes>
<include>com.clickhouse:clickhouse-data</include>
<include>com.clickhouse:clickhouse-client</include>
<include>org.lz4:lz4-pure-java</include>
<include>org.lz4:lz4-java</include>
</includes>
</artifactSet>
<relocations>
Expand Down
8 changes: 4 additions & 4 deletions clickhouse-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-pure-java</artifactId>
<artifactId>lz4-java</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down Expand Up @@ -425,7 +425,7 @@
<include>org.apache.httpcomponents.core5:httpcore5</include>
<include>org.apache.httpcomponents.core5:httpcore5-h2</include>
<include>com.clickhouse:jdbc-v2</include>
<include>org.lz4:lz4-pure-java</include>
<include>org.lz4:lz4-java</include>
</includes>
</artifactSet>
<relocations>
Expand Down Expand Up @@ -495,7 +495,7 @@
<include>org.apache.httpcomponents.client5:httpclient5</include>
<include>org.apache.httpcomponents.core5:httpcore5</include>
<include>org.apache.httpcomponents.core5:httpcore5-h2</include>
<include>org.lz4:lz4-pure-java</include>
<include>org.lz4:lz4-java</include>
<include>com.clickhouse:jdbc-v2</include>
<include>com.clickhouse:client-v2</include>
</includes>
Expand Down Expand Up @@ -573,7 +573,7 @@
<include>com.clickhouse:clickhouse-data</include>
<include>com.clickhouse:clickhouse-client</include>
<include>com.clickhouse:clickhouse-http-client</include>
<include>org.lz4:lz4-pure-java</include>
<include>org.lz4:lz4-java</include>
</includes>
</artifactSet>
<relocations>
Expand Down
2 changes: 1 addition & 1 deletion client-v2/docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ the document keeps historical information about the dependencies.
- `com.clickhouse:clickhouse-client:jar:0.7.1-patch1-SNAPSHOT:compile` - Required because there is an option to use client-v1. Additionally, this dependency is required because a few core classes like `ClickHouseNode` are used in client-v2. When client-v1 is deprecated - all required classes should be moved to client-v2 module and this dependency will be removed.
- `org.slf4j:slf4j-api:jar:2.0.7:compile` - Most commonly used logging frontend.
- `org.apache.commons:commons-compress:jar:1.27.1:compile` - Required for compression.
- `org.lz4:lz4-pure-java:jar:1.8.0:compile` - Required for compression.
- `org.lz4:lz4-java:jar:1.8.0:compile` - Required for compression.
- `org.ow2.asm:asm:jar:9.7:compile` - Required for serialization/deserialization.
- `org.apache.httpcomponents.client5:httpclient5:jar:5.3.1:compile` - only HTTP client that is currently supported. In the future it should be an optional dependency when support for different clients will be added. This client also implements async API that might be used in the future.
- `com.fasterxml.jackson.core:jackson-core:jar:2.17.2:compile` - used to safely parse summary from ClickHouse.
Expand Down
2 changes: 1 addition & 1 deletion client-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-pure-java</artifactId>
<artifactId>lz4-java</artifactId>
<version>${lz4.version}</version>
</dependency>

Expand Down
6 changes: 3 additions & 3 deletions jdbc-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-pure-java</artifactId>
<artifactId>lz4-java</artifactId>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -173,7 +173,7 @@
<include>org.apache.httpcomponents.client5:httpclient5</include>
<include>org.apache.httpcomponents.core5:httpcore5</include>
<include>org.apache.httpcomponents.core5:httpcore5-h2</include>
<include>org.lz4:lz4-pure-java</include>
<include>org.lz4:lz4-java</include>
</includes>
</artifactSet>
<relocations>
Expand Down Expand Up @@ -311,7 +311,7 @@
<include>com.clickhouse:clickhouse-data</include>
<include>com.clickhouse:client-v2</include>
<include>com.clickhouse:clickhouse-http-client</include>
<include>org.lz4:lz4-pure-java</include>
<include>org.lz4:lz4-java</include>
</includes>
</artifactSet>
<relocations>
Expand Down
20 changes: 10 additions & 10 deletions performance/src/test/com/clickhouse/benchmark/BenchmarkRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ public static void main(String[] args) throws Exception {
Map<String, String> argMap = parseArguments(args);

Options opt = new OptionsBuilder()
.include(QueryClient.class.getName())
.include(InsertClient.class.getName())
.include(ConcurrentInsertClient.class.getName())
.include(ConcurrentQueryClient.class.getName())
// .include(QueryClient.class.getName())
// .include(InsertClient.class.getName())
// .include(ConcurrentInsertClient.class.getName())
// .include(ConcurrentQueryClient.class.getName())
.include(Compression.class.getName())
.include(Serializers.class.getName())
.include(Deserializers.class.getName())
.include(MixedWorkload.class.getName())
.include(DataTypes.class.getName())
.include(JDBCQuery.class.getName())
.include(JDBCInsert.class.getName())
// .include(Serializers.class.getName())
// .include(Deserializers.class.getName())
// .include(MixedWorkload.class.getName())
// .include(DataTypes.class.getName())
// .include(JDBCQuery.class.getName())
// .include(JDBCInsert.class.getName())
.forks(1) // must be a fork. No fork only for debugging
.mode(Mode.SampleTime)
.timeUnit(TimeUnit.MILLISECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public void CompressingOutputStreamV1(DataState dataState) {
}

private static final LZ4Factory factory = LZ4Factory.fastestInstance();
private static final LZ4Factory nativeFactory = LZ4Factory.nativeInstance();
private static final LZ4Factory javaSafeFactory = LZ4Factory.safeInstance();
private static final LZ4Factory javaUnSafeFactory = LZ4Factory.safeInstance();


@Benchmark
public void CompressingOutputStreamV2(DataState dataState) {
Expand All @@ -44,4 +48,47 @@ public void CompressingOutputStreamV2(DataState dataState) {
LOGGER.error("Error: ", e);
}
}

@Benchmark
public void CompressingOutputStreamV2Native(DataState dataState) {
DataSet dataSet = dataState.dataSet;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ClickHouseLZ4OutputStream out = new ClickHouseLZ4OutputStream(baos,
nativeFactory.fastCompressor(), COMPRESS_BUFFER_SIZE)) {
for (byte[] bytes : dataSet.getBytesList(dataSet.getFormat())) {
out.write(bytes);
}
} catch (Exception e) {
LOGGER.error("Error: ", e);
}
}

@Benchmark
public void CompressingOutputStreamV2Unsafe(DataState dataState) {
DataSet dataSet = dataState.dataSet;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ClickHouseLZ4OutputStream out = new ClickHouseLZ4OutputStream(baos,
javaUnSafeFactory.fastCompressor(), COMPRESS_BUFFER_SIZE)) {
for (byte[] bytes : dataSet.getBytesList(dataSet.getFormat())) {
out.write(bytes);
}
} catch (Exception e) {
LOGGER.error("Error: ", e);
}
}

@Benchmark
public void CompressingOutputStreamV2safe(DataState dataState) {
DataSet dataSet = dataState.dataSet;
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ClickHouseLZ4OutputStream out = new ClickHouseLZ4OutputStream(baos,
javaSafeFactory.fastCompressor(), COMPRESS_BUFFER_SIZE)) {
for (byte[] bytes : dataSet.getBytesList(dataSet.getFormat())) {
out.write(bytes);
}
} catch (Exception e) {
LOGGER.error("Error: ", e);
}
}

}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<artifactId>lz4-pure-java</artifactId>
<version>${lz4.version}</version>
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-pure-java</artifactId>
<artifactId>lz4-java</artifactId>
<version>${lz4.version}</version>
</dependency>
<dependency>
Expand Down
Loading