DBZ-742 Basic perf comparison of MySQL parsers
This commit is contained in:
parent
90a453b0ee
commit
142e68e060
101
debezium-microbenchmark/pom.xml
Normal file
101
debezium-microbenchmark/pom.xml
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0"?>
|
||||
<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">
|
||||
<parent>
|
||||
<groupId>io.debezium</groupId>
|
||||
<artifactId>debezium-parent</artifactId>
|
||||
<version>0.8.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>debezium-microbenchmark</artifactId>
|
||||
<name>Debezium Microbenchmark Tests</name>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.debezium</groupId>
|
||||
<artifactId>debezium-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.debezium</groupId>
|
||||
<artifactId>debezium-connector-mysql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<resources>
|
||||
<!-- Apply the properties set in the POM to the resource files -->
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/build.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>**/generated/**</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
|
||||
<resource>MANIFEST.MF</resource>
|
||||
</transformer>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||
<mainClass>org.openjdk.jmh.Main</mainClass>
|
||||
</transformer>
|
||||
</transformers>
|
||||
<filters>
|
||||
<filter>
|
||||
<!--
|
||||
Shading signed JARs will fail without this.
|
||||
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
|
||||
-->
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright Debezium Authors.
|
||||
*
|
||||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package io.debezium.performance.connector.mysql.parser;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||
import org.openjdk.jmh.annotations.Fork;
|
||||
import org.openjdk.jmh.annotations.Level;
|
||||
import org.openjdk.jmh.annotations.Measurement;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.annotations.OutputTimeUnit;
|
||||
import org.openjdk.jmh.annotations.Param;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.annotations.Warmup;
|
||||
|
||||
import io.debezium.connector.mysql.MySqlDdlParser;
|
||||
import io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser;
|
||||
import io.debezium.relational.Tables;
|
||||
import io.debezium.relational.ddl.AbstractDdlParser;
|
||||
|
||||
/**
|
||||
* A basic test to compare performance of legacy and antlr DDL parsers depending on the amount
|
||||
* of columns in the statement.
|
||||
*
|
||||
* @author Jiri Pechanec <jpechane@redhat.com>
|
||||
*
|
||||
*/
|
||||
public class MySqlDdlParserPerf {
|
||||
|
||||
@State(Scope.Thread)
|
||||
public static class ParserState {
|
||||
|
||||
public AbstractDdlParser legacyParser;
|
||||
public AbstractDdlParser antlrParser;
|
||||
public Tables tables;
|
||||
public String ddl;
|
||||
|
||||
@Param({"1", "2", "5", "10", "20", "50"})
|
||||
public int columnCount;
|
||||
|
||||
|
||||
@Setup(Level.Trial)
|
||||
public void doSetup() {
|
||||
legacyParser = new MySqlDdlParser();
|
||||
antlrParser = new MySqlAntlrDdlParser();
|
||||
tables = new Tables();
|
||||
ddl = testStatement();
|
||||
}
|
||||
|
||||
private String testStatement() {
|
||||
final StringBuilder sb = new StringBuilder("CREATE TABLE t1 (id int primary key");
|
||||
for (int i = 0; i < columnCount; i++) {
|
||||
sb.append(", v").append(i).append(" int");
|
||||
}
|
||||
final String statement = sb.append(")").toString();
|
||||
return statement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
@Fork(value = 1)
|
||||
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 3, time = 2, timeUnit = TimeUnit.SECONDS)
|
||||
public void legacy(ParserState state) {
|
||||
state.legacyParser.parse(state.ddl, state.tables);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
@Fork(value = 1)
|
||||
@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS)
|
||||
@Measurement(iterations = 3, time = 2, timeUnit = TimeUnit.SECONDS)
|
||||
public void antlr(ParserState state) {
|
||||
state.antlrParser.parse(state.ddl, state.tables);
|
||||
}
|
||||
}
|
14
pom.xml
14
pom.xml
@ -82,8 +82,9 @@
|
||||
<!-- Testing -->
|
||||
<version.junit>4.12</version.junit>
|
||||
<version.fest>1.4</version.fest>
|
||||
<version.jmh>1.21</version.jmh>
|
||||
|
||||
<!-- Maven Plugins -->
|
||||
<!-- Maven Plugins -->
|
||||
<version.resources.plugin>2.7</version.resources.plugin>
|
||||
<version.dependency.plugin>2.10</version.dependency.plugin>
|
||||
<version.enforcer.plugin>3.0.0-M1</version.enforcer.plugin>
|
||||
@ -121,6 +122,7 @@
|
||||
<module>debezium-connector-mysql</module>
|
||||
<module>debezium-connector-postgres</module>
|
||||
<module>debezium-connector-mongodb</module>
|
||||
<module>debezium-microbenchmark</module>
|
||||
</modules>
|
||||
|
||||
<distributionManagement>
|
||||
@ -298,6 +300,16 @@
|
||||
<artifactId>fest-assert</artifactId>
|
||||
<version>${version.fest}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>${version.jmh}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>${version.jmh}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Debezium artifacts -->
|
||||
<dependency>
|
||||
|
Loading…
Reference in New Issue
Block a user