Skip to content
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

test: add benchmark tools #1800

Merged
merged 22 commits into from
May 25, 2022
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
51 changes: 51 additions & 0 deletions benchmark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# OpenMLDB Benchmark

OpenMLDB Benchmak tool is used for tesing the performance of OpenMLDB's online SQL engine.

## Requirements

- CentOS 7 / macOS >= 10.15
- JDK 1.8

## Run

1. Compile
```bash
cd benchmark
mvn clean package
```
2. Uncompress the package to `lib` dir and copy the configuration to `conf` dir
```bash
mkdir -p /work/benchmark/conf /work/benchmark/lib
cp target/openmldb-benchmark-0.5.0.jar /work/benchmark/lib
cp src/main/resources/conf.properties /work/benchmark/conf
cd /work/benchmark/lib && jar -xvf openmldb-benchmark-0.5.0.jar
```
3. Modify the configuration
```
ZK_CLUSTER=127.0.0.1:32200
ZK_PATH=/udf_test
```
4. Run benchmark
```
cd /work/benchmark
java -cp conf/:lib/ com._4paradigm.openmldb.benchmark.OpenMLDBPerfBenchmark
```

The above testing run with the default confguration. You can modify `WINDOW_NUM`, `WINDOW_SIZE` and `JOIN_NUM` in the confguration file if you want to evaluate the performance impact of those parameters.

Moreover, the default number of threads is 10. You need to set the thread number by `Threads` annotation in `OpenMLDBPerfBenchmark.java` or `OpenMLDBLongWindowBenchmark.java` as below and compile again if you want to test under other thread confguration.
```java
@Threads(10)
```
If you want to test `Throughput`, set `BenchmarkMode` and `OutputTimeUnit` annotation in `OpenMLDBPerfBenchmark.java` or `OpenMLDBLongWindowBenchmark.java` file as below:
```java
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
```

### Long Window Benchmark (The Pre-Aggregate Optimization)
Update `WINDOW_SIZE` in confguration file and execute the following command.
```
java -cp conf/:lib/ com._4paradigm.openmldb.benchmark.OpenMLDBLongWindowBenchmark
```
115 changes: 115 additions & 0 deletions benchmark/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>com.4paradigm.openmldb</groupId>
<artifactId>openmldb-benchmark</artifactId>
<packaging>jar</packaging>
<name>openmldb-benchmark</name>
<version>0.5.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.32</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.32</version>
</dependency>
<dependency>
<groupId>com.4paradigm.openmldb</groupId>
<artifactId>openmldb-jdbc</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>com.4paradigm.openmldb</groupId>
<artifactId>openmldb-native</artifactId>
<version>0.5.0-allinone</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.32</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.8</version>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<forkMode>always</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<!-- put your configurations here -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.0.0</version>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2021 4Paradigm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com._4paradigm.openmldb.benchmark;

import com._4paradigm.openmldb.sdk.SdkOption;
import com._4paradigm.openmldb.sdk.SqlExecutor;
import com._4paradigm.openmldb.sdk.impl.SqlClusterExecutor;

import java.util.Properties;

public class BenchmarkConfig {
public static String ZK_CLUSTER = "127.0.0.1:6181";
public static String ZK_PATH="/onebox";

public static String DATABASE = "";
public static int WINDOW_NUM = 2;
public static int WINDOW_SIZE = 1000;
public static int JOIN_NUM = 2;
public static int PK_BASE = 1000000;
public static long TS_BASE = 1652232079000l;
public static String DEPLOY_NAME;

private static SqlExecutor executor = null;
private static SdkOption option = null;

public static int PK_NUM = 1;
public static int PK_MAX = 0;
static {
try {
Properties prop = new Properties();
prop.load(BenchmarkConfig.class.getClassLoader().getResourceAsStream("conf.properties"));
ZK_CLUSTER = prop.getProperty("ZK_CLUSTER");
ZK_PATH = prop.getProperty("ZK_PATH");
TS_BASE = Long.parseLong(prop.getProperty("TS_BASE"));
PK_BASE = Integer.parseInt(prop.getProperty("PK_BASE"));
DATABASE = prop.getProperty("DATABASE");
DEPLOY_NAME = prop.getProperty("DEPLOY_NAME");
WINDOW_NUM = Integer.valueOf(prop.getProperty("WINDOW_NUM"));
WINDOW_SIZE = Integer.valueOf(prop.getProperty("WINDOW_SIZE"));
JOIN_NUM = Integer.valueOf(prop.getProperty("JOIN_NUM"));
PK_NUM = Integer.valueOf(prop.getProperty("PK_NUM", "100000"));
PK_MAX = Integer.valueOf(prop.getProperty("PK_MAX", "0"));

} catch (Exception e) {
e.printStackTrace();
}

}

public static SqlExecutor GetSqlExecutor(boolean enableDebug) {
if (executor != null) {
return executor;
}
SdkOption sdkOption = new SdkOption();
sdkOption.setSessionTimeout(30000);
sdkOption.setZkCluster(BenchmarkConfig.ZK_CLUSTER);
sdkOption.setZkPath(BenchmarkConfig.ZK_PATH);
sdkOption.setEnableDebug(enableDebug);
sdkOption.setRequestTimeout(1000000);
option = sdkOption;
try {
executor = new SqlClusterExecutor(option);
} catch (Exception e) {
e.printStackTrace();
}
return executor;
}
}
Loading