Skip to content

Commit

Permalink
Update flux samples to Boot 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Jul 23, 2018
1 parent fe86594 commit 7ea4c67
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
22 changes: 21 additions & 1 deletion flux/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,24 @@ MiniBenchmark.mini demo ss 10 0.255 ± 0.007 s/op 2255
```

Strangely the "boot" sample doesn't benefit at all from the
combination (it's not faster with J9 once the lazy beans are on).
combination (it's not faster with J9 once the lazy beans are on).

== Spring Boot 2.1.0

Spring 5.1 has some performance improvements.

```
Benchmark (sample) Mode Cnt Score Error Units
MainBenchmark.main empt ss 10 0.596 ± 0.010 s/op
MainBenchmark.main jlog ss 10 0.770 ± 0.022 s/op
MainBenchmark.main demo ss 10 0.939 ± 0.037 s/op
MainBenchmark.main actr ss 10 1.270 ± 0.025 s/op
MainBenchmark.main jdbc ss 10 1.057 ± 0.018 s/op
MainBenchmark.main actj ss 10 1.449 ± 0.059 s/op
MiniBenchmark.boot jlog ss 10 0.458 ± 0.007 s/op
MiniBenchmark.boot demo ss 10 0.572 ± 0.014 s/op
MiniBenchmark.micro jlog ss 10 0.199 ± 0.013 s/op
MiniBenchmark.micro demo ss 10 0.304 ± 0.003 s/op
MiniBenchmark.mini jlog ss 10 0.412 ± 0.022 s/op
MiniBenchmark.mini demo ss 10 0.529 ± 0.013 s/op
```
4 changes: 2 additions & 2 deletions flux/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<java.version>1.8</java.version>
<jmh.version>1.16</jmh.version>
<aspectj.version>1.8.13</aspectj.version>
<spring-boot.version>2.0.2.RELEASE</spring-boot.version>
<spring-boot.version>2.1.0.BUILD-SNAPSHOT</spring-boot.version>
<spring-cloud.version>Finchley.BUILD-SNAPSHOT</spring-cloud.version>
<locator.version>1.0.0.RELEASE</locator.version>
<thin.version>1.0.8.RELEASE</thin.version>
<thin.version>1.0.12.RELEASE</thin.version>
<uberjar.name>benchmarks</uberjar.name>
<start-class>org.openjdk.jmh.Main</start-class>
</properties>
Expand Down
3 changes: 2 additions & 1 deletion flux/src/main/java/com/example/bench/MainBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.example.bench;

import com.example.demo.DemoApplication;
import com.example.empt.EmptyApplication;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
Expand Down Expand Up @@ -46,7 +47,7 @@ public void main(MainState state) throws Exception {
public static class MainState extends ProcessLauncherState {

public static enum Sample {
empt, jlog, demo, actr, jdbc, actj;
empt(EmptyApplication.class), jlog, demo, actr, jdbc, actj;

private Class<?> config;

Expand Down
12 changes: 8 additions & 4 deletions flux/src/main/java/com/example/config/ApplicationBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.example.config;

import java.time.Duration;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand All @@ -25,7 +27,7 @@
import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
import org.springframework.web.server.adapter.WebHttpHandlerBuilder;

import reactor.ipc.netty.http.server.HttpServer;
import reactor.netty.http.server.HttpServer;

/**
* @author Dave Syer
Expand All @@ -48,9 +50,11 @@ public static void start(ConfigurableApplicationContext context) {

HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build();
ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
HttpServer httpServer = HttpServer.create("localhost",
context.getEnvironment().getProperty("server.port", Integer.class, 8080));
httpServer.startAndAwait(adapter);
HttpServer httpServer = HttpServer.create().host("localhost").port(
context.getEnvironment().getProperty("server.port", Integer.class, 8080))
.handle(adapter);
httpServer.bindUntilJavaShutdown(Duration.ofSeconds(60),
disposable -> disposable.dispose());
}

private static boolean hasListeners(ConfigurableApplicationContext context) {
Expand Down
14 changes: 14 additions & 0 deletions flux/src/main/java/com/example/empt/EmptyApplication.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.empt;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

@SpringBootApplication
// @Import(LazyInitBeanFactoryPostProcessor.class)
public class EmptyApplication {

public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(EmptyApplication.class).run(args);
}

}
2 changes: 1 addition & 1 deletion flux/src/main/resources/META-INF/thin.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spring-boot.version=2.0.0.RELEASE
# spring-boot.version=2.0.0.RELEASE
dependencies.spring-boot-starter-web=org.springframework.boot:spring-boot-starter-webflux
exclusions.jmh-core=org.openjdk.jmh:jmh-core
exclusions.spring-boot-thin-launcher=org.springframework.boot.experimental:spring-boot-thin-launcher
Expand Down

0 comments on commit 7ea4c67

Please sign in to comment.