Skip to content

Commit

Permalink
Merge pull request #8 from SOLID-Design/concurrency_improvement
Browse files Browse the repository at this point in the history
Concurrency improvement
  • Loading branch information
sirpiotrek authored Nov 29, 2018
2 parents a474e43 + 595fed1 commit 588fbc0
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ target/
test-output/
.settings/
*.iml
*.swp
.idea/
.idea/*
.project
Expand Down
32 changes: 31 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.rtbhouse</groupId>
<artifactId>avro-fastserde</artifactId>
<version>1.0.2</version>
<version>1.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<name>avro-fastserde</name>
Expand Down Expand Up @@ -183,6 +183,13 @@
<excludes>
<exclude>**/generated/**/*.java</exclude>
</excludes>
<annotationProcessorPaths>
<path>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -287,6 +294,29 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/benchmarks.xml</descriptor>
</descriptors>
<archive>
<manifest>
<mainClass>org.openjdk.jmh.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
42 changes: 42 additions & 0 deletions src/main/assembly/benchmarks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">

<id>benchmarks</id>
<formats>
<format>jar</format>
</formats>

<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>test</scope>
<unpackOptions>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.directory}/test-classes</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/*</include>
</includes>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>
160 changes: 91 additions & 69 deletions src/main/java/com/rtbhouse/utils/avro/FastSerdeCache.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.rtbhouse.utils.generated.avro.benchmark.LargeAndDeep;

@State(Scope.Thread)
@State(Scope.Benchmark)
@Fork(1)
public class LargeAndDeepRecordBenchmark extends RecordBenchmarkBase<LargeAndDeep> {

Expand All @@ -34,27 +34,27 @@ public void fastGenericDatumWriter() throws Exception {

@Benchmark
public void genericDatumWriter() throws Exception {
super.genericDatumWriter();
super.genericDatumWriter();
}

@Benchmark
public void fastSpecificDatumReader() throws Exception {
super.fastSpecificDatumReader();
super.fastSpecificDatumReader();
}

@Benchmark
public void specificDatumReader() throws Exception {
super.specificDatumReader();
super.specificDatumReader();
}

@Benchmark
public void fastSpecificDatumWriter() throws Exception {
super.fastSpecificDatumWriter();
super.fastSpecificDatumWriter();
}

@Benchmark
public void specificDatumWriter() throws Exception {
super.specificDatumWriter();
super.specificDatumWriter();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.rtbhouse.utils.generated.avro.benchmark.LargeAndFlat;

@State(Scope.Thread)
@State(Scope.Benchmark)
@Fork(1)
public class LargeAndFlatRecordBenchmark extends RecordBenchmarkBase<LargeAndFlat> {

Expand All @@ -34,27 +34,27 @@ public void fastGenericDatumWriter() throws Exception {

@Benchmark
public void genericDatumWriter() throws Exception {
super.genericDatumWriter();
super.genericDatumWriter();
}

@Benchmark
public void fastSpecificDatumReader() throws Exception {
super.fastSpecificDatumReader();
super.fastSpecificDatumReader();
}

@Benchmark
public void specificDatumReader() throws Exception {
super.specificDatumReader();
super.specificDatumReader();
}

@Benchmark
public void fastSpecificDatumWriter() throws Exception {
super.fastSpecificDatumWriter();
super.fastSpecificDatumWriter();
}

@Benchmark
public void specificDatumWriter() throws Exception {
super.specificDatumWriter();
super.specificDatumWriter();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import com.rtbhouse.utils.avro.FastSpecificDatumWriter;

public abstract class RecordBenchmarkBase<T extends SpecificRecord> {
private static final FastSerdeCache cache = new FastSerdeCache(Runnable::run);

protected Schema specificRecordSchema;

private List<GenericData.Record> genericRecords = new ArrayList<>();
private List<T> specificRecords = new ArrayList<>();
private List<byte[]> recordBytes = new ArrayList<>();
private FastSerdeCache cache;

private FastGenericDatumReader<GenericData.Record> fastGenericDatumReader;
private FastGenericDatumWriter<GenericData.Record> fastGenericDatumWriter;
Expand All @@ -43,8 +43,6 @@ public abstract class RecordBenchmarkBase<T extends SpecificRecord> {

@Setup
public void init() throws Exception {
cache = new FastSerdeCache(Runnable::run);

final GenericDatumWriter<GenericData.Record> datumWriter = new GenericDatumWriter<>(specificRecordSchema);
for (int i = 0; i < 1000; i++) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.rtbhouse.utils.generated.avro.benchmark.SmallAndDeep;

@State(Scope.Thread)
@State(Scope.Benchmark)
@Fork(1)
public class SmallAndDeepRecordBenchmark extends RecordBenchmarkBase<SmallAndDeep> {

Expand All @@ -34,27 +34,27 @@ public void fastGenericDatumWriter() throws Exception {

@Benchmark
public void genericDatumWriter() throws Exception {
super.genericDatumWriter();
super.genericDatumWriter();
}

@Benchmark
public void fastSpecificDatumReader() throws Exception {
super.fastSpecificDatumReader();
super.fastSpecificDatumReader();
}

@Benchmark
public void specificDatumReader() throws Exception {
super.specificDatumReader();
super.specificDatumReader();
}

@Benchmark
public void fastSpecificDatumWriter() throws Exception {
super.fastSpecificDatumWriter();
super.fastSpecificDatumWriter();
}

@Benchmark
public void specificDatumWriter() throws Exception {
super.specificDatumWriter();
super.specificDatumWriter();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.rtbhouse.utils.generated.avro.benchmark.SmallAndFlat;

@State(Scope.Thread)
@State(Scope.Benchmark)
@Fork(1)
public class SmallAndFlatRecordBenchmark extends RecordBenchmarkBase<SmallAndFlat> {

Expand All @@ -34,27 +34,27 @@ public void fastGenericDatumWriter() throws Exception {

@Benchmark
public void genericDatumWriter() throws Exception {
super.genericDatumWriter();
super.genericDatumWriter();
}

@Benchmark
public void fastSpecificDatumReader() throws Exception {
super.fastSpecificDatumReader();
super.fastSpecificDatumReader();
}

@Benchmark
public void specificDatumReader() throws Exception {
super.specificDatumReader();
super.specificDatumReader();
}

@Benchmark
public void fastSpecificDatumWriter() throws Exception {
super.fastSpecificDatumWriter();
super.fastSpecificDatumWriter();
}

@Benchmark
public void specificDatumWriter() throws Exception {
super.specificDatumWriter();
super.specificDatumWriter();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import com.rtbhouse.utils.generated.avro.benchmark.UnionSmallAndDeep;

@State(Scope.Thread)
@State(Scope.Benchmark)
@Fork(1)
public class UnionSmallAndDeepRecordBenchmark extends RecordBenchmarkBase<UnionSmallAndDeep> {

Expand All @@ -34,27 +34,27 @@ public void fastGenericDatumWriter() throws Exception {

@Benchmark
public void genericDatumWriter() throws Exception {
super.genericDatumWriter();
super.genericDatumWriter();
}

@Benchmark
public void fastSpecificDatumReader() throws Exception {
super.fastSpecificDatumReader();
super.fastSpecificDatumReader();
}

@Benchmark
public void specificDatumReader() throws Exception {
super.specificDatumReader();
super.specificDatumReader();
}

@Benchmark
public void fastSpecificDatumWriter() throws Exception {
super.fastSpecificDatumWriter();
super.fastSpecificDatumWriter();
}

@Benchmark
public void specificDatumWriter() throws Exception {
super.specificDatumWriter();
super.specificDatumWriter();
}

}

0 comments on commit 588fbc0

Please sign in to comment.