Skip to content

Small fixes benchmark #2246

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

Merged
merged 3 commits into from
Mar 25, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception {
.timeUnit(TimeUnit.MILLISECONDS)
.addProfiler(GCProfiler.class)
.addProfiler(MemPoolProfiler.class)
.warmupIterations(1)
.warmupIterations(3)
.warmupTime(TimeValue.seconds(5))
.measurementIterations(10)
.jvmArgs("-Xms8g", "-Xmx8g")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,32 @@ protected static Client getClientV2(boolean includeDb) {
.setDefaultDatabase(includeDb ? DB_NAME : "default")
.build();
}

private static String jdbcURLV1(boolean isCloud) {
ClickHouseNode node = getServer();
if (isCloud) {
return String.format("jdbc:clickhouse://%s:%s?clickhouse.jdbc.v1=true&ssl=true", node.getHost(), node.getPort());
} else
return String.format("jdbc:clickhouse://%s:%s?clickhouse.jdbc.v1=true", node.getHost(), node.getPort());
}

private static String jdbcURLV2(boolean isCloud) {
ClickHouseNode node = getServer();
if (isCloud) {
return String.format("jdbc:clickhouse://%s:%s?ssl=true", node.getHost(), node.getPort());
} else
return String.format("jdbc:clickhouse://%s:%s", node.getHost(), node.getPort());
}

protected static Connection getJdbcV1() {
Properties properties = new Properties();
properties.put("user", getUsername());
properties.put("password", getPassword());

ClickHouseNode node = getServer();

Connection jdbcV1 = null;
String jdbcURL = jdbcURLV1(isCloud());
LOGGER.info("JDBC URL: " + jdbcURL);
try {
jdbcV1 = new ClickHouseDriver().connect(String.format("jdbc:clickhouse://%s:%s?clickhouse.jdbc.v1=true", node.getHost(), node.getPort()), properties);
jdbcV1 = new ClickHouseDriver().connect(jdbcURL, properties);
} catch (SQLException e) {
LOGGER.error(e.getMessage());
}
Expand All @@ -286,10 +302,12 @@ protected static Connection getJdbcV2() {
properties.put("user", getUsername());
properties.put("password", getPassword());

ClickHouseNode node = getServer();
Connection jdbcV2 = null;
String jdbcURL = jdbcURLV1(isCloud());
LOGGER.info("JDBC URL: " + jdbcURL);

try {
jdbcV2 = new ClickHouseDriver().connect(String.format("jdbc:clickhouse://%s:%s", node.getHost(), node.getPort()), properties);
jdbcV2 = new ClickHouseDriver().connect(jdbcURL, properties);
} catch (SQLException e) {
LOGGER.error(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.clickhouse.benchmark.clients;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.TearDown;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -14,6 +16,27 @@

public class JDBCInsert extends BenchmarkBase {
private static final Logger LOGGER = LoggerFactory.getLogger(JDBCInsert.class);
@TearDown(Level.Invocation)
public void verifyRowsInsertedAndCleanup(DataState dataState) {
boolean success;
int count = 0;
do {
success = verifyCount(dataState.tableNameEmpty, dataState.dataSet.getSize());
if (!success) {
LOGGER.warn("Retrying to verify rows inserted");
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
LOGGER.error("Error: ", e);
}
}
} while (!success && count++ < 10);
if (!success) {
LOGGER.error("Failed to verify rows inserted");
throw new RuntimeException("Failed to verify rows inserted");
}
truncateTable(dataState.tableNameEmpty);
}
void insetData(Connection connection, DataState dataState) throws SQLException {
int size = dataState.dataSet.getSchema().getColumns().size();
String names = dataState.dataSet.getSchema().getColumns().stream().map(column -> column.getColumnName()).collect(Collectors.joining(","));
Expand Down
Loading