Skip to content

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

Closed

Description

@zloster

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

Activity

  1. zloster commented on Mar 22, 2017

    @zloster
    OwnerAuthor

    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.

  2. zloster commented on Mar 22, 2017

    @zloster
    OwnerAuthor

    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
    
  3. zloster commented on Mar 22, 2017

    @zloster
    OwnerAuthor

    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.
  4. zloster commented on Apr 1, 2017

    @zloster
    OwnerAuthor

    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.

  5. zloster commented on Apr 2, 2017

    @zloster
    OwnerAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions