eclipse-ee4j / metro-jax-ws

metro-jax-ws
https://eclipse-ee4j.github.io/metro-jax-ws/
BSD 3-Clause "New" or "Revised" License
70 stars 40 forks source link

JAX WS builtin Server implementation is very slow on Linux #594

Closed Tomas-Kraus closed 2 years ago

Tomas-Kraus commented 2 years ago

Previously tracked at: https://bugs.openjdk.java.net/browse/JDK-8193236 FULL PRODUCT VERSION : openjdk version "1.8.0_151" OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-1~deb9u1-b12) OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)

ADDITIONAL OS VERSION INFORMATION : Linux c0ab5270bb70 4.9.49-moby #1 SMP Wed Sep 27 23:17:17 UTC 2017 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM : The built-in JAX WS server implementation works 100 times slower on linux machines then on Mac OS X or Windows. JMH test is published here: https://github.com/Andremoniy/linuxjvmjaxwstest

Basically it does the following: 1) starts a JAX WS with one SOAP method: endpoint = Endpoint.publish("http://localhost:8888/", new FooServiceImpl()); 2) performs client requests to this method: String result = state.client.foo(state.foo);

On Mac OS X with 2 Cores Intel Core i7 it gives:

JMH version: 1.19

VM version: JDK 1.8.0_151, VM 25.151-b12

VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/jre/bin/java

... Result "test.openjdk.MyBenchmark.testMethod": 3077.813 ±(99.9%) 51.818 ops/s [Average] (min, avg, max) = (1718.347, 3077.813, 3315.271), stdev = 219.400 CI (99.9%): [3025.995, 3129.630] (assumes normal distribution)

Run complete. Total time: 00:06:49

Benchmark Mode Cnt Score Error Units MyBenchmark.testMethod thrpt 200 3077.813 ± 51.818 ops/s

The same machine, docker without CPU limitations:

JMH version: 1.19

VM version: JDK 1.8.0_151, VM 25.151-b12

VM invoker: /usr/java/jdk1.8.0_151/jre/bin/java

... Result "test.openjdk.MyBenchmark.testMethod": 19.882 ?(99.9%) 0.169 ops/s [Average] (min, avg, max) = (10.031, 19.882, 20.104), stdev = 0.715 CI (99.9%): [19.714, 20.051] (assumes normal distribution)

Run complete. Total time: 00:07:01

Benchmark Mode Cnt Score Error Units MyBenchmark.testMethod thrpt 200 19.882 ? 0.169 ops/s

The situation changes if JAX WS server is started with Jetty (there is no performance issues): ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection(); server.setHandler(contextHandlerCollection);

JettyHttpServerProvider.setServer(server); 
HttpContext context = new JettyHttpServerProvider().createHttpServer(new InetSocketAddress(8888), 5).createContext("/"); 

Endpoint endpoint = Endpoint.create(new MyBenchmark.FooServiceImpl()); 
endpoint.publish(context); 

server.start(); 

Please, refer also: https://stackoverflow.com/questions/47645817/jax-ws-server-implementation-performance-issue-for-linux-jvm

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : On linux machine (for instance, docker pull openjdk:8u151)

git init git clone https://github.com/Andremoniy/openjdkjaxwstest mvn package cd target java -jar benchmark.jar

EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The performance should be the about 3000-5000 ops/s. ACTUAL - The performance is about 20 ops/s.

REPRODUCIBILITY : This bug can be reproduced always.

---------- BEGIN SOURCE ---------- https://github.com/Andremoniy/linuxjvmjaxwstest ---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND : Use Jetty server for publishing WS.

Source: https://github.com/javaee/metro-jax-ws/issues/1219 Author: LanceAndersen

Tomas-Kraus commented 2 years ago

Here is test fork with dependencies and code update to build the test with latest development snapshot: https://github.com/Tomas-Kraus/linuxjvmjaxwstest Tested on my Mac: openjdk version "17" 2021-09-14 OpenJDK Runtime Environment (build 17+35-2724) OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)

# Run complete. Total time: 00:06:46
Benchmark                Mode  Cnt      Score    Error  Units
MyBenchmark.testMethod  thrpt  200  10009.949 ± 33.048  ops/s

...so let's try Linux now ...

I got some 23-25 ops/s. So the problem still exists in master branch.

Tomas-Kraus commented 2 years ago

Running Java VM with -Dsun.net.httpserver.nodelay=true seems to solve the issue on Linux:

# Run complete. Total time: 00:00:13

Benchmark                Mode  Cnt     Score     Error  Units
MyBenchmark.testMethod  thrpt   10  6152.077 ± 831.090  ops/s
Tomas-Kraus commented 2 years ago

Related topics:

lukasj commented 2 years ago

release noted in #612