mirror of https://github.com/grpc/grpc-java.git
Move jmh benchmarks to their respective modules
The benchmarks should be close to the code they're benchmarking, like we do with tests. This includes a bugfix to SerializingExecutorBenchmark to let it run. The io.grpc.benchmarks.netty benchmarks in benchmarks/ depend on ByteBufOutputMarshaller from benchmarks's main, so they were not moved.
This commit is contained in:
parent
812e65a5ca
commit
6164b7b2ee
|
@ -1,20 +1,12 @@
|
|||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath libraries.math
|
||||
classpath libraries.protobuf_plugin
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "me.champeau.gradle.jmh" version "0.4.4"
|
||||
}
|
||||
|
||||
apply plugin: 'application'
|
||||
|
||||
description = "grpc Benchmarks"
|
||||
|
@ -23,11 +15,10 @@ startScripts.enabled = false
|
|||
run.enabled = false
|
||||
|
||||
jmh {
|
||||
jmhVersion = '1.19'
|
||||
warmupIterations = 10
|
||||
iterations = 10
|
||||
fork = 1
|
||||
jvmArgs = "-server -Xms2g -Xmx2g"
|
||||
// Workaround
|
||||
// https://github.com/melix/jmh-gradle-plugin/issues/97#issuecomment-316664026
|
||||
includeTests = true
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -50,10 +41,6 @@ compileJava {
|
|||
options.compilerArgs += ["-Xep:JavaLangClash:OFF"]
|
||||
}
|
||||
|
||||
compileJmhJava {
|
||||
options.compilerArgs = compileJava.options.compilerArgs
|
||||
}
|
||||
|
||||
configureProtoCompilation()
|
||||
|
||||
def vmArgs = [
|
||||
|
|
19
build.gradle
19
build.gradle
|
@ -10,6 +10,7 @@ buildscript {
|
|||
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
|
||||
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0'
|
||||
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.11'
|
||||
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +22,7 @@ subprojects {
|
|||
apply plugin: "signing"
|
||||
apply plugin: "jacoco"
|
||||
|
||||
apply plugin: "me.champeau.gradle.jmh"
|
||||
apply plugin: "com.google.osdetector"
|
||||
// The plugin only has an effect if a signature is specified
|
||||
apply plugin: "ru.vyarus.animalsniffer"
|
||||
|
@ -57,7 +59,7 @@ subprojects {
|
|||
mavenLocal()
|
||||
}
|
||||
|
||||
[compileJava, compileTestJava].each() {
|
||||
[compileJava, compileTestJava, compileJmhJava].each() {
|
||||
it.options.compilerArgs += ["-Xlint:all", "-Xlint:-options", "-Xlint:-path"]
|
||||
it.options.encoding = "UTF-8"
|
||||
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
|
||||
|
@ -165,7 +167,7 @@ subprojects {
|
|||
}
|
||||
}
|
||||
|
||||
[compileJava, compileTestJava].each() {
|
||||
[compileJava, compileTestJava, compileJmhJava].each() {
|
||||
// Protobuf-generated code produces some warnings.
|
||||
// https://github.com/google/protobuf/issues/2718
|
||||
it.options.compilerArgs += ["-Xlint:-cast", "-Xep:MissingOverride:OFF",
|
||||
|
@ -227,6 +229,9 @@ subprojects {
|
|||
|
||||
// Configuration for modules that use Jetty ALPN agent
|
||||
alpnagent libraries.jetty_alpn_agent
|
||||
|
||||
jmh 'org.openjdk.jmh:jmh-core:1.19',
|
||||
'org.openjdk.jmh:jmh-generator-bytecode:1.19'
|
||||
}
|
||||
|
||||
signing {
|
||||
|
@ -261,6 +266,16 @@ subprojects {
|
|||
source = fileTree(dir: "src/test", include: "**/*.java")
|
||||
}
|
||||
|
||||
jmh {
|
||||
warmupIterations = 10
|
||||
iterations = 10
|
||||
fork = 1
|
||||
// None of our benchmarks need the tests, and we have pseudo-circular
|
||||
// dependencies that break when including them. (context's testCompile
|
||||
// depends on core; core's testCompile depends on testing)
|
||||
includeTests = false
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
classifier = 'javadoc'
|
||||
from javadoc
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.grpc.context;
|
||||
package io.grpc;
|
||||
|
||||
import io.grpc.Context;
|
||||
import io.grpc.Context.Key;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
|
@ -14,9 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.grpc.context;
|
||||
package io.grpc;
|
||||
|
||||
import io.grpc.Context;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
|
@ -14,9 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.grpc.context;
|
||||
package io.grpc;
|
||||
|
||||
import io.grpc.Context;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
|
@ -18,3 +18,8 @@ javadoc {
|
|||
exclude 'io/grpc/Internal?*.java'
|
||||
exclude 'io/grpc/internal/**'
|
||||
}
|
||||
|
||||
animalsniffer {
|
||||
// Don't check sourceSets.jmh
|
||||
sourceSets = [sourceSets.main, sourceSets.test]
|
||||
}
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.grpc.benchmarks;
|
||||
package io.grpc;
|
||||
|
||||
import io.grpc.CallOptions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
|
@ -18,6 +18,7 @@ package io.grpc.internal;
|
|||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Phaser;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
|
@ -39,7 +40,7 @@ import org.openjdk.jmh.annotations.TearDown;
|
|||
@State(Scope.Thread)
|
||||
public class SerializingExecutorBenchmark {
|
||||
|
||||
private ExecutorService executorService;
|
||||
private ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
private Executor executor = new SerializingExecutor(executorService);
|
||||
|
||||
private static class IncrRunnable implements Runnable {
|
||||
|
@ -94,4 +95,4 @@ public class SerializingExecutorBenchmark {
|
|||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,3 +29,9 @@ project.sourceSets {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
jmh {
|
||||
// Workaround
|
||||
// https://github.com/melix/jmh-gradle-plugin/issues/97#issuecomment-316664026
|
||||
includeTests = true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue