Skip to content
Open
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
1 change: 0 additions & 1 deletion agent-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ jar {
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove [Test] from the PR name to mark this as ready for review

}
}

1 change: 1 addition & 0 deletions agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ tasks.withType(GenerateModuleMetadata) {
enabled = false
}


2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a particular reason for updating Gradle in this PR?

networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion src/jmh/java/benchmark/BenchmarkUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class BenchmarkUtils {

@SuppressWarnings("UnstableApiUsage")
static String loadResource(String name) {
public static String loadResource(String name) {
return asRTE(() -> {
URL resource = BenchmarkUtils.class.getClassLoader().getResource(name);
if (resource == null) {
Expand Down
248 changes: 248 additions & 0 deletions src/jmh/java/performance/AstPrinterPerformance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
package performance;

import graphql.language.AstPrinter;
import graphql.language.Document;
import graphql.parser.Parser;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 2, time = 5)
@Measurement(iterations = 3, time = 10)
@Fork(3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I will later add as an ArchUnit test, we usually have 2 forks in GraphQL Java JMH tests to keep the running time shorter

public class AstPrinterPerformance {
/**
* Note: this query is a redacted version of a real query
*/
private static final Document document = Parser.parse("query fang($slip: dinner!) {\n" +
" instinctive(thin: $slip) {\n" +
" annoy {\n" +
" ...account\n" +
" }\n" +
" massive {\n" +
" ...cellar\n" +
" }\n" +
" used {\n" +
" ...rinse\n" +
" }\n" +
" distinct(sedate: [disarm]) {\n" +
" ...lamp\n" +
" }\n" +
" venomous {\n" +
" uninterested\n" +
" }\n" +
" correct {\n" +
" ...plane\n" +
" }\n" +
" drown\n" +
" talk {\n" +
" house\n" +
" womanly\n" +
" royal {\n" +
" ...snore\n" +
" }\n" +
" gray\n" +
" normal\n" +
" proud\n" +
" crate\n" +
" billowy {\n" +
" frogs\n" +
" abstracted\n" +
" market\n" +
" corn\n" +
" }\n" +
" tip {\n" +
" ...public\n" +
" }\n" +
" stick {\n" +
" ...precious\n" +
" }\n" +
" null {\n" +
" ...precious\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n" +
"\n" +
"fragment account on bath {\n" +
" purpose\n" +
" festive\n" +
" ruddy\n" +
"}\n" +
"\n" +
"fragment cellar on thunder {\n" +
" debonair\n" +
" immense\n" +
" object\n" +
" moon\n" +
" icy {\n" +
" furniture\n" +
" historical\n" +
" team\n" +
" root\n" +
" }\n" +
"}\n" +
"\n" +
"fragment rinse on song {\n" +
" reply {\n" +
" sticks\n" +
" unbecoming\n" +
" }\n" +
" love {\n" +
" annoying\n" +
" sign\n" +
" }\n" +
"}\n" +
"\n" +
"fragment lamp on heartbreaking {\n" +
" innocent\n" +
" decorate\n" +
" pancake\n" +
" arithmetic\n" +
" grey\n" +
" brass\n" +
" pocket\n" +
"}\n" +
"\n" +
"fragment snore on tired {\n" +
" share\n" +
" baseball\n" +
" suspend\n" +
"}\n" +
"\n" +
"fragment settle on incompetent {\n" +
" name\n" +
" juggle\n" +
" depressed\n" +
"}\n" +
"\n" +
"fragment few on puffy {\n" +
" ticket\n" +
" puny\n" +
" copy\n" +
" coast\n" +
"}\n" +
"\n" +
"fragment plane on seat {\n" +
" ice\n" +
" mug\n" +
" wobble\n" +
" clear\n" +
" toys {\n" +
" ...few\n" +
" }\n" +
"}\n" +
"\n" +
"fragment public on basin {\n" +
" different\n" +
" fang\n" +
" slip\n" +
" dinner\n" +
" instinctive\n" +
" thin {\n" +
" annoy {\n" +
" account\n" +
" massive\n" +
" cellar\n" +
" used\n" +
" rinse {\n" +
" distinct\n" +
" }\n" +
" sedate {\n" +
" disarm\n" +
" }\n" +
" lamp {\n" +
" venomous\n" +
" }\n" +
" }\n" +
" uninterested {\n" +
" ...settle\n" +
" }\n" +
" }\n" +
"}\n" +
"\n" +
"fragment precious on drown {\n" +
" talk\n" +
" house\n" +
" womanly\n" +
" royal {\n" +
" snore {\n" +
" gray\n" +
" }\n" +
" normal {\n" +
" proud\n" +
" crate\n" +
" billowy\n" +
" frogs\n" +
" abstracted {\n" +
" ...snore\n" +
" }\n" +
" corn {\n" +
" tip\n" +
" public\n" +
" }\n" +
" stick {\n" +
" ...settle\n" +
" }\n" +
" null {\n" +
" ...few\n" +
" }\n" +
" marry\n" +
" bath {\n" +
" purpose\n" +
" festive\n" +
" }\n" +
" ruddy\n" +
" help\n" +
" thunder\n" +
" debonair {\n" +
" immense\n" +
" }\n" +
" object\n" +
" }\n" +
" }\n" +
"}");

@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
public void benchMarkAstPrinterThroughput(Blackhole blackhole) {
printAst(blackhole);
}

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void benchMarkAstPrinterAvgTime(Blackhole blackhole) {
printAst(blackhole);
}

public static void printAst(Blackhole blackhole) {
blackhole.consume(AstPrinter.printAst(document));
}

@Benchmark
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
public void benchMarkAstPrinterCompactThroughput(Blackhole blackhole) {
printAstCompact(blackhole);
}

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void benchMarkAstPrinterCompactAvgTime(Blackhole blackhole) {
printAstCompact(blackhole);
}

public static void printAstCompact(Blackhole blackhole) {
blackhole.consume(AstPrinter.printAstCompact(document));
}
}
46 changes: 46 additions & 0 deletions src/jmh/java/performance/CreateSchemaPerformance.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package performance;

import benchmark.BenchmarkUtils;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 2, time = 5)
@Measurement(iterations = 3)
@Fork(3)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this to 2 forks please?

public class CreateSchemaPerformance {

static String largeSDL = BenchmarkUtils.loadResource("large-schema-3.graphqls");
static String extraLargeSDL = BenchmarkUtils.loadResource("extra-large-schema-1.graphqls");

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void benchmarkLargeSchemaCreateAvgTime(Blackhole blackhole) {
blackhole.consume(createSchema(largeSDL));
}

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public void benchmarkExtraLargeSchemaCreateAvgTime(Blackhole blackhole) {
blackhole.consume(createSchema(extraLargeSDL));
}

private static GraphQLSchema createSchema(String sdl) {
TypeDefinitionRegistry registry = new SchemaParser().parse(sdl);
return new SchemaGenerator().makeExecutableSchema(registry, RuntimeWiring.MOCKED_WIRING);
}
}
Loading
Loading