Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JVM tunning flags in the start scripts for dropwizard #5

Closed
zloster opened this issue Mar 22, 2017 · 5 comments
Closed

Add JVM tunning flags in the start scripts for dropwizard #5

zloster opened this issue Mar 22, 2017 · 5 comments
Milestone

Comments

@zloster
Copy link
Owner

zloster commented Mar 22, 2017

It is a big endeavor to attempt fine tuning the JVM arguments.
But some basic stuff will not harm. Use the other Java projects for reference. But note that some of them are using outdated or currently default settings.

Update:
Track the progress in this branch: https://github.com/zloster/FrameworkBenchmarks/tree/jvm-params

@zloster
Copy link
Owner Author

zloster commented Mar 22, 2017

The command to get the current settings is:
grep -rn10 --include="*.sh" "^java"

  • -r is a recursive search in the files hierarchy
  • n tells grep to report the line number in the file if there is a match
  • --include="*.sh" tells grep to look only in files with .sh extention
  • "^java" tells grep to search for match only at the beginning of a text line

Update: some setup scripts break the command line on several physical lines with \ at the end of the line. So I've added 10 to the grep options to print the next 10 lines after match.

@zloster
Copy link
Owner Author

zloster commented Mar 22, 2017

The projects with JVM tunning options:

  • The special case is: frameworks/Java/act/setup.sh:24:java -server $JAVA_OPTS -Dapp.mode=prod -Dapp.nodeGroup=$GROUP -Dprofile=prod -Dmongo.host=${DBHOST} -Dmysql.host=${DBHOST} -Dpgsql.host=${DBHOST} -cp "$CP" $APP_ENTRY &
    JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Dawt.useSystemAAFontSettings=on -server -Xms512m -Xmx2g" The change to /dev/urandom SHOULD receive investigation and if affecting results -> rule clarifications
  • frameworks/Clojure/aleph/setup.sh:8:java -server -Xmx2g -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -jar target/*-standalone.jar &
  • frameworks/Clojure/http-kit/setup.sh:15:java -server -jar target/http-kit-standalone.jar &
  • frameworks/Clojure/luminus/setup.sh:13:java -server -jar target/hello.jar &
  • frameworks/Clojure/pedestal/setup.sh:16:java -jar -D"io.pedestal.log.defaultMetricsRecorder=nil" -D"io.pedestal.log.overrideLogger=nil" target/pedestal-standalone.jar &
  • frameworks/Java/bayou/setup.sh:7:java -jar bayou_TFB-0.1-jar-with-dependencies.jar &
  • frameworks/Java/dropwizard/setup_mongo.sh:9:java -jar target/hello-world-0.0.1-SNAPSHOT.jar server hello-world-mongo.yml &
  • frameworks/Java/dropwizard/setup_mysql.sh:9:java -jar target/hello-world-0.0.1-SNAPSHOT.jar server hello-world-mysql.yml &
  • frameworks/Java/dropwizard/setup_postgresql.sh:9:java -jar target/hello-world-0.0.1-SNAPSHOT.jar server hello-world-postgres.yml &
  • frameworks/Java/grizzly-bm/setup.sh:8:java -Dorg.glassfish.grizzly.nio.transport.TCPNIOTransport.max-receive-buffer-size=16384 -Dorg.glassfish.grizzly.http.io.OutputBuffer.default-buffer-size=1024 -Dorg.glassfish.grizzly.memory.BuffersBuffer.bb-cache-size=32 -jar grizzly-bm-0.1-jar-with-dependencies.jar &
  • frameworks/Java/grizzly-jersey/setup.sh:7:java -jar target/grizzly-jersey-example.jar -dbhost ${DBHOST} &
  • frameworks/Java/jetty-servlet/setup.sh:8:java -jar jetty-servlet-example-0.2-jar-with-dependencies.jar &
  • frameworks/Java/jlhttp/setup.sh:11:java -server -Xss256k -XX:+UseNUMA -XX:+UseParallelGC -XX:+AggressiveOpts -jar jlhttp-1.0-jar-with-dependencies.jar &
  • frameworks/Java/jooby/setup.sh:10:java -server -XX:+UseNUMA -XX:+UseParallelGC -XX:+AggressiveOpts -jar jooby-1.0.jar &
  • frameworks/Java/light-java/setup.sh:7:java -server -Xms512m -Xmx2g -jar techempower-1.0.0.jar &
  • frameworks/Java/netty/setup.sh:8:java -server -XX:+UseNUMA -XX:+UseParallelGC -XX:+AggressiveOpts -jar netty-example-0.1-jar-with-dependencies.jar &
  • frameworks/Java/ninja-standalone/setup.sh:10:java -Dninja.port=8080 -jar target/ninja-standalone-0.0.1-SNAPSHOT-jar-with-dependencies.jar &
  • frameworks/Java/permeagility/setup.sh:6:java -jar target/permeagility-0.1.0-SNAPSHOT-benchmark.jar &
  • frameworks/Java/restexpress/setup.sh:13:java -jar world-1.0-SNAPSHOT.jar &
  • frameworks/Java/spring/setup.sh:7:java -Ddatabase.host=${DBHOST} -jar spring.war &
  • frameworks/Java/undertow-jersey-c3p0/setup.sh:7:java -jar target/undertow-jersey.jar -dbhost ${DBHOST} &
  • frameworks/Java/undertow-jersey-hikaricp/setup.sh:7:java -jar target/undertow-jersey.jar -dbhost ${DBHOST} &
  • frameworks/Java/undertow/setup.sh:9:java -jar undertow-example-0.1-jar-with-dependencies.jar &
  • frameworks/Java/vertx/setup.sh:8:java -Xms2G -Xmx2G -server -XX:+UseNUMA -XX:+UseParallelGC -XX:+AggressiveOpts -Dvertx.disableWebsockets=true -Dvertx.flashPolicyHandler=false -Dvertx.threadChecks=false -Dvertx.disableContextTimings=true -Dvertx.disableTCCL=true -jar vertx.benchmark-0.0.1-SNAPSHOT-fat.jar &
  • [x]frameworks/Java/vertx-web/setup.sh:9:java -Xms2G -Xmx2G -server -XX:+UseNUMA -XX:+UseParallelGC -XX:+AggressiveOpts -Dvertx.disableWebsockets=true -Dvertx.flashPolicyHandler=false -Dvertx.threadChecks=false -Dvertx.disableContextTimings=true -Dvertx.disableTCCL=true -jar target/vertx-benchmark-1.0.0-SNAPSHOT-fat.jar --instances grep --count ^processor /proc/cpuinfo --conf src/main/conf/config.json &
  • frameworks/Scala/akka-http/setup.sh:10:java -server -jar target/scala-2.11/akka-http-benchmark.jar &
  • frameworks/Scala/blaze/setup.sh:7:java -jar target/scala-2.11/blaze*one-jar.jar &
  • frameworks/Scala/finagle/setup.sh:7:java -jar target/scala-2.11/finagleone-jar.jar &
  • frameworks/Scala/finch/setup.sh:7:java -jar target/scala-2.11/finchone-jar.jar &
  • frameworks/Scala/fintrospect/setup.sh:9:java -Dcom.twitter.finagle.toggle.flag.overrides=com.twitter.http.UseNetty4=1.0 -server -XX:+UseNUMA -XX:+UseParallelGC -XX:+AggressiveOpts -XX:+AlwaysPreTouch -jar target/scala-2.11/fintrospectone-jar.jar &
  • frameworks/Scala/http4s/setup.sh:7:java -jar target/scala-2.11/http4s*one-jar.jar "${DBHOST}" &
  • frameworks/Scala/scruffy/setup.sh:9:java -jar target/scala-2.11/scruffy-benchmark-assembly-11.0.jar -Dhostname=${DBHOST} &
  • frameworks/Scala/spray/setup.sh:7:java -jar target/scala-2.11/spray-benchmark-assembly-1.0.jar &

Update: resin is using properties configuration file: https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/toolset/setup/linux/webservers/resin/resin.properties#L82-L84

# Arg passed directly to the JVM
jvm_args  : -Xmx2048m -Xms2048m -XX:MaxPermSize=256m
jvm_mode    : -server

@zloster
Copy link
Owner Author

zloster commented Mar 22, 2017

Notes:

  1. Last time I've checked -XX:+UseNUMA check was not enabled by default in the JVM. The Physical machines are NUMA. So enabling explicitly should help. How much? I can't be sure - don't have access to NUMA machine. But if the test load is generating a lot of garbage which probably is the case it should help. Also it seems that this could help on the cloud instances in Azure: they are using Azure D3v2 which is using Intel® Xeon® Processor E5-2673 v2. It is possible to use 2 physical processors in one server (read the specs). So this instances are NUMA if the servers have 2 physical CPUs.
    From the documentation:

The NUMA-aware allocator can be turned on with the -XX:+UseNUMA flag in conjunction with the selection of the Parallel Scavenger garbage collector. The Parallel Scavenger garbage collector is the default for a server-class machine. The Parallel Scavenger garbage collector can also be turned on explicitly by specifying the -XX:+UseParallelGC option.

  1. -server seems not to be needed any more. If the platform is 64-bit and there is more than 2 GB of RAM the JVM is choosing the -server option.

@zloster
Copy link
Owner Author

zloster commented Apr 1, 2017

The following are relatively conservative options for the JVM.

JAVA_OPTS="-Xms1G -Xmx1G -Xss320k -XX:+UseNUMA -XX:+UseParallelGC -XX:+AggressiveOpts"
-server $JAVA_OPTS

Requests 1 and only 1GB of RAM, adjust call-stack size to 320 kibibytes (kilobytes by the old rulse, thanks to HDD marketing departments), enable NUMA architecture support which helps the GC threads to be local on the CPU for which RAM area they are responsible for cleaning, enable additional bytecode optimizations which are experimental and not enabled by default for the current JVM release version.

Notes about resin:
The current TFB configuration is available in the following two files:

  1. resin.properties
  2. resin.xml

However the option jvm-mode: -server is not described in the documentation. So the -server declaration is moved to jvm-args. Also the requested RAM is decreased to 1GB. Applications are free to change these options in their resin.xml. Also obsolete setting about the perm-gen memory is removed.

@zloster
Copy link
Owner Author

zloster commented Apr 2, 2017

Pull request submitted for Dropwizard, Jetty, Resin and Undertow. 2652.

@zloster zloster closed this as completed Apr 2, 2017
zloster pushed a commit that referenced this issue Oct 2, 2018
Here's an example of the error output from before this change:

Unhandled exception:
Bad state: Stream was already listened to
#0      _RawServerSocket.listen (dart:io-patch/socket_patch.dart:1106)
#1      new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:123)
#2      _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:91)
#3      _ForwardingStream.listen (dart:async/stream_pipe.dart:86)
#4      _ServerSocket.listen (dart:io-patch/socket_patch.dart:1351)
#5      _HttpServer.listen (dart:io/http_impl.dart:2278)
#6      _startServer.<anonymous closure> (file:///server.dart:88:12)
#7      _RootZone.runUnary (dart:async/zone.dart:1371)
#8      _FutureListener.handleValue (dart:async/future_impl.dart:129)
#9      _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636)
#10     _Future._propagateToListeners (dart:async/future_impl.dart:665)
#11     _Future._completeWithValue (dart:async/future_impl.dart:478)
#12     Future.wait.<anonymous closure> (dart:async/future.dart:362)
#13     _RootZone.runUnary (dart:async/zone.dart:1371)
#14     _FutureListener.handleValue (dart:async/future_impl.dart:129)
#15     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636)
#16     _Future._propagateToListeners (dart:async/future_impl.dart:665)
#17     _Future._completeWithValue (dart:async/future_impl.dart:478)
#18     Future.wait.<anonymous closure> (dart:async/future.dart:362)
#19     _RootZone.runUnary (dart:async/zone.dart:1371)
#20     _FutureListener.handleValue (dart:async/future_impl.dart:129)
#21     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:636)
#22     _Future._propagateToListeners (dart:async/future_impl.dart:665)
#23     _Future._completeWithValue (dart:async/future_impl.dart:478)
#24     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:510)
#25     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#26     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#27     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:99)
#28     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:152)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant