# Java OpenJDK 8

This page describes the Optimization Pack for Java OpenJDK 8 JVM.

## Metrics

### Memory

| Metric                          | Unit    | Description                                                              |
| ------------------------------- | ------- | ------------------------------------------------------------------------ |
| mem\_used                       | bytes   | The total amount of memory used                                          |
| jvm\_heap\_size                 | bytes   | The size of the JVM heap memory                                          |
| jvm\_heap\_used                 | bytes   | The amount of heap memory used                                           |
| jvm\_heap\_util                 | percent | The utilization % of heap memory                                         |
| jvm\_off\_heap\_used            | bytes   | The amount of non-heap memory used                                       |
| jvm\_heap\_old\_gen\_used       | bytes   | The amount of heap memory used (old generation)                          |
| jvm\_heap\_young\_gen\_used     | bytes   | The amount of heap memory used (young generation)                        |
| jvm\_heap\_old\_gen\_size       | bytes   | The size of the JVM heap memory (old generation)                         |
| jvm\_heap\_young\_gen\_size     | bytes   | The size of the JVM heap memory (young generation)                       |
| jvm\_memory\_used               | bytes   | The total amount of memory used across all the JVM memory pools          |
| jvm\_heap\_committed            | bytes   | The size of the JVM committed memory                                     |
| jvm\_memory\_buffer\_pool\_used | bytes   | The total amount bytes used by buffers within the JVM buffer memory pool |

### CPU

| Metric    | Unit    | Description                                                                                                     |
| --------- | ------- | --------------------------------------------------------------------------------------------------------------- |
| cpu\_util | percent | The average CPU utilization % across all the CPUs (i.e., how much time on average the CPUs are busy doing work) |
| cpu\_used | CPUs    | The total amount of CPUs used                                                                                   |

### Garbage Collection

| Metric            | Unit          | Description                                                                               |
| ----------------- | ------------- | ----------------------------------------------------------------------------------------- |
| jvm\_gc\_time     | percent       | The % of wall clock time the JVM spent doing stop the world garbage collection activities |
| jvm\_gc\_count    | collections/s | The total number of stop the world JVM garbage collections that have occurred per second  |
| jvm\_gc\_duration | seconds       | The average duration of a stop the world JVM garbage collection                           |

### Other metrics

| Metric                   | Unit         | Description                                                     |
| ------------------------ | ------------ | --------------------------------------------------------------- |
| jvm\_threads\_current    | threads      | The total number of active threads within the JVM               |
| jvm\_threads\_deadlocked | threads      | The total number of deadlocked threads within the JVM           |
| jvm\_compilation\_time   | milliseconds | The total time spent by the JVM JIT compiler compiling bytecode |

## Parameters

### Memory

| Name                          | Type        | Unit      | Dafault                                   | Domain                                                 | Restart | Description                                                                                                                                                      |
| ----------------------------- | ----------- | --------- | ----------------------------------------- | ------------------------------------------------------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| jvm\_minHeapSize              | integer     | megabytes | You should select your own default value. | You should select your own domain.                     | yes     | The minimum heap size.                                                                                                                                           |
| jvm\_maxHeapSize              | integer     | megabytes | You should select your own default value. | You should select your own domain.                     | yes     | The maximum heap size.                                                                                                                                           |
| jvm\_maxRAM                   | integer     | megabytes | You should select your own default value. | You should select your own domain.                     | yes     | The maximum amount of memory used by the JVM.                                                                                                                    |
| jvm\_initialRAMPercentage     | real        | percent   | `1.563`                                   | `0.1` → `100`                                          | yes     | The initial percentage of memory used by the JVM.                                                                                                                |
| jvm\_maxRAMPercentage         | real        | percent   | `25.0`                                    | `0.1` → `100.0`                                        | yes     | The percentage of memory used for maximum heap size, on systems with large physical memory size (more than 512MB). Requires Java 10, Java 8 Update 191 or later. |
| jvm\_alwaysPreTouch           | categorical |           | `-AlwaysPreTouch`                         | `+AlwaysPreTouch`, `-AlwaysPreTouch`                   | yes     | Pretouch pages during initialization.                                                                                                                            |
| jvm\_metaspaceSize            | integer     | megabytes | `20`                                      | You should select your own domain within 1 and 1024    | yes     | The initial size of the allocated class metadata space.                                                                                                          |
| jvm\_maxMetaspaceSize         | integer     | megabytes | `20`                                      | You should select your own domain within 1 and 1024    | yes     | The maximum size of the allocated class metadata space.                                                                                                          |
| jvm\_useTransparentHugePages  | categorical |           | `-UseTransparentHugePages`                | `+UseTransparentHugePages`, `-UseTransparentHugePages` | yes     | Enables the use of large pages that can dynamically grow or shrink.                                                                                              |
| jvm\_allocatePrefetchInstr    | integer     |           | `0`                                       | `0` → `3`                                              | yes     | Prefetch ahead of the allocation pointer.                                                                                                                        |
| jvm\_allocatePrefetchDistance | integer     | bytes     | `0`                                       | `0` → `512`                                            | yes     | Distance to prefetch ahead of allocation pointer. -1 use system-specific value (automatically determined).                                                       |
| jvm\_allocatePrefetchLines    | integer     | lines     | `3`                                       | `1` → `64`                                             | yes     | The number of lines to prefetch ahead of array allocation pointer.                                                                                               |
| jvm\_allocatePrefetchStyle    | integer     |           | `1`                                       | `0` → `3`                                              | yes     | Selects the prefetch instruction to generate.                                                                                                                    |
| jvm\_useLargePages            | categorical |           | `+UseLargePages`                          | `+UseLargePages`, `-UseLargePages`                     | yes     | Enable the use of large page memory.                                                                                                                             |

### Garbage Collection

| Name                                  | Type        | Unit         | Default                                   | Domain                                                             | Restart | Description                                                                                                                                                                                        |
| ------------------------------------- | ----------- | ------------ | ----------------------------------------- | ------------------------------------------------------------------ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| jvm\_newRatio                         | integer     |              | `2`                                       | `0` → `2147483647`                                                 | yes     | The ratio of old/new generation sizes.                                                                                                                                                             |
| jvm\_newSize                          | integer     | megabytes    | You should select your own default value. | You should select your own domain.                                 | yes     | Sets the initial and maximum size of the heap for the young generation (nursery).                                                                                                                  |
| jvm\_maxNewSize                       | integer     | megabytes    | You should select your own default value. | You should select your own domain.                                 | yes     | Specifies the upper bound for the young generation size.                                                                                                                                           |
| jvm\_survivorRatio                    | integer     |              | `8`                                       | `1` → `100`                                                        | yes     | The ratio between the Eden and each Survivor-space within the JVM. For example, a jvm\_survivorRatio would mean that the Eden-space is 6 times one Survivor-space.                                 |
| jvm\_useAdaptiveSizePolicy            | categorical |              | `+UseAdaptiveSizePolicy`                  | `+UseAdaptiveSizePolicy`, `-UseAdaptiveSizePolicy`                 | yes     | Enable adaptive generation sizing. Disable coupled with jvm\_targetSurvivorRatio.                                                                                                                  |
| jvm\_adaptiveSizePolicyWeight         | integer     |              | `10`                                      | `0` → `100`                                                        | yes     | The weighting given to the current Garbage Collection time versus previous GC times when checking the timing goal.                                                                                 |
| jvm\_targetSurvivorRatio              | integer     |              | `50`                                      | `1` → `100`                                                        | yes     | The desired percentage of Survivor-space used after young garbage collection.                                                                                                                      |
| jvm\_minHeapFreeRatio                 | integer     |              | `40`                                      | `1` → `99`                                                         | yes     | The minimum percentage of heap free after garbage collection to avoid shrinking.                                                                                                                   |
| jvm\_maxHeapFreeRatio                 | integer     |              | `70`                                      | `0` → `100`                                                        | yes     | The maximum percentage of heap free after garbage collection to avoid shrinking.                                                                                                                   |
| jvm\_maxTenuringThreshold             | integer     |              | `15`                                      | `0` → `15`                                                         | yes     | The maximum value for the tenuring threshold.                                                                                                                                                      |
| jvm\_gcType                           | categorical |              | `Parallel`                                | `Serial`, `Parallel`, `ConcMarkSweep`, `G1`, `ParNew`              | yes     | Type of the garbage collection algorithm.                                                                                                                                                          |
| jvm\_concurrentGCThreads              | integer     | threads      | You should select your own default value. | You should select your own domain.                                 | yes     | The number of threads concurrent garbage collection will use.                                                                                                                                      |
| jvm\_parallelGCThreads                | integer     | threads      | You should select your own default value. | You should select your own domain.                                 | yes     | The number of threads garbage collection will use for parallel phases.                                                                                                                             |
| jvm\_maxGCPauseMillis                 | integer     | milliseconds | `200`                                     | `1` → `1000`                                                       | yes     | Adaptive size policy maximum GC pause time goal in millisecond.                                                                                                                                    |
| jvm\_resizePLAB                       | categorical |              | `+ResizePLAB`                             | `+ResizePLAB`, `-ResizePLAB`                                       | yes     | Enables the dynamic resizing of promotion LABs.                                                                                                                                                    |
| jvm\_GCTimeRatio                      | integer     |              | `99`                                      | `0` → `100`                                                        | yes     | The target fraction of time that can be spent in garbage collection before increasing the heap, computet as 1 / (1 + GCTimeRatio).                                                                 |
| jvm\_initiatingHeapOccupancyPercent   | integer     |              | `45`                                      | `0` → `100`                                                        | yes     | Sets the percentage of the heap occupancy at which to start a concurrent GC cycle.                                                                                                                 |
| jvm\_youngGenerationSizeIncrement     | integer     |              | `20`                                      | `0` → `100`                                                        | yes     | The increment size for Young Generation adaptive resizing.                                                                                                                                         |
| jvm\_tenuredGenerationSizeIncrement   | integer     |              | `20`                                      | `0` → `100`                                                        | yes     | The increment size for Old/Tenured Generation adaptive resizing.                                                                                                                                   |
| jvm\_adaptiveSizeDecrementScaleFactor | integer     |              | `4`                                       | `1` → `1024`                                                       | yes     | Specifies the scale factor for goal-driven generation resizing.                                                                                                                                    |
| jvm\_CMSTriggerRatio                  | integer     |              | `80`                                      | `0` → `100`                                                        | yes     | The percentage of MinHeapFreeRatio allocated before CMS GC starts                                                                                                                                  |
| jvm\_CMSInitiatingOccupancyFraction   | integer     |              | `-1`                                      | `-1` → `99`                                                        | yes     | Configure oldgen occupancy fraction threshold for CMS GC. Negative values default to CMSTriggerRatio.                                                                                              |
| jvm\_CMSClassUnloadingEnabled         | categorical |              | `+CMSClassUnloadingEnabled`               | `+CMSClassUnloadingEnabled`, `-CMSClassUnloadingEnabled`           | yes     | Enables class unloading when using CMS.                                                                                                                                                            |
| jvm\_useCMSInitiatingOccupancyOnly    | categorical |              | `-UseCMSInitiatingOccupancyOnly`          | `+UseCMSInitiatingOccupancyOnly`, `-UseCMSInitiatingOccupancyOnly` | yes     | Use of the occupancy value as the only criterion for initiating the CMS collector.                                                                                                                 |
| jvm\_G1HeapRegionSize                 | integer     | megabytes    | `8`                                       | `1`→`32`                                                           | yes     | Sets the size of the regions for G1.                                                                                                                                                               |
| jvm\_G1ReservePercent                 | integer     |              | `10`                                      | `0` → `50`                                                         | yes     | Sets the percentage of the heap that is reserved as a false ceiling to reduce the possibility of promotion failure for the G1 collector.                                                           |
| jvm\_G1NewSizePercent                 | integer     |              | `5`                                       | `0` → `100`                                                        | yes     | Sets the percentage of the heap to use as the minimum for the young generation size.                                                                                                               |
| jvm\_G1MaxNewSizePercent              | integer     |              | `60`                                      | `0` → `100`                                                        | yes     | Sets the percentage of the heap size to use as the maximum for young generation size.                                                                                                              |
| jvm\_G1MixedGCLiveThresholdPercent    | integer     |              | `85`                                      | `0` → `100`                                                        | yes     | Sets the occupancy threshold for an old region to be included in a mixed garbage collection cycle.                                                                                                 |
| jvm\_G1HeapWastePercent               | integer     |              | `5`                                       | `0` → `100`                                                        | yes     | The maximum percentage of the reclaimable heap before starting mixed GC.                                                                                                                           |
| jvm\_G1MixedGCCountTarget             | integer     | collections  | `8`                                       | `0` → `100`                                                        | yes     | Sets the target number of mixed garbage collections after a marking cycle to collect old regions with at most G1MixedGCLIveThresholdPercent live data. The default is 8 mixed garbage collections. |
| jvm\_G1OldCSetRegionThresholdPercent  | integer     |              | `10`                                      | `0` → `100`                                                        | yes     | The upper limit on the number of old regions to be collected during mixed GC.                                                                                                                      |

### Compilation

| Name                              | Type        | Unit      | Default                                   | Domain                                             | Restart | Description                                                                                       |
| --------------------------------- | ----------- | --------- | ----------------------------------------- | -------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------- |
| jvm\_reservedCodeCacheSize        | integer     | megabytes | `240`                                     | `3` → `2048`                                       | yes     | The maximum size of the compiled code cache pool.                                                 |
| jvm\_tieredCompilation            | categorical |           | `+TieredCompilation`                      | `+TieredCompilation`, `-TieredCompilation`         | yes     | The type of the garbage collection algorithm.                                                     |
| jvm\_tieredCompilationStopAtLevel | integer     |           | `4`                                       | `0` → `4`                                          | yes     | Overrides the number of detected CPUs that the VM will use to calculate the size of thread pools. |
| jvm\_compilationThreads           | integer     | threads   | You should select your own default value. | You should select your own domain.                 | yes     | The number of compilation threads.                                                                |
| jvm\_backgroundCompilation        | categorical |           | `+BackgroundCompilation`                  | `+BackgroundCompilation`, `-BackgroundCompilation` | yes     | Allow async interpreted execution of a method while it is being compiled.                         |
| jvm\_inline                       | categorical |           | `+Inline`                                 | `+Inline`, `-Inline`                               | yes     | Enable inlining.                                                                                  |
| jvm\_maxInlineSize                | integer     | bytes     | `35`                                      | `1` → `2097152`                                    | yes     | The bytecode size limit (in bytes) of the inlined methods.                                        |
| jvm\_inlineSmallCode              | integer     | bytes     | `2000`                                    | `1` → `16384`                                      | yes     | The maximum compiled code size limit (in bytes) of the inlined methods.                           |

### Other parameters

| Name                      | Type        | Unit | Default             | Domain                                   | Restart | Description                                                                                       |
| ------------------------- | ----------- | ---- | ------------------- | ---------------------------------------- | ------- | ------------------------------------------------------------------------------------------------- |
| jvm\_aggressiveOpts       | categorical |      | `-AggressiveOpts`   | `+AggressiveOpts`, `-AggressiveOpts`     | yes     | Turn on point performance compiler optimizations.                                                 |
| jvm\_usePerfData          | categorical |      | `+UsePerfData`      | `+UsePerfData`, `-UsePerfData`           | yes     | Enable monitoring of performance data.                                                            |
| jvm\_useNUMA              | categorical |      | `-UseNUMA`          | `+UseNUMA`, `-UseNUMA`                   | yes     | Enable NUMA.                                                                                      |
| jvm\_useBiasedLocking     | categorical |      | `+UseBiasedLocking` | `+UseBiasedLocking`, `-UseBiasedLocking` | yes     | Manage the use of biased locking.                                                                 |
| jvm\_activeProcessorCount | integer     | CPUs | `1`                 | `1` → `512`                              | yes     | Overrides the number of detected CPUs that the VM will use to calculate the size of thread pools. |

## Domains

The following parameters require their ranges or default values to be updated according to the described rules:

| **Parameter**             | **Default value**                  | **Domain**                               |
| ------------------------- | ---------------------------------- | ---------------------------------------- |
| jvm\_minHeapSize          |                                    | Depends on the instance available memory |
| jvm\_maxHeapSize          |                                    | Depends on the instance available memory |
| jvm\_newSize              |                                    | Depends on the configured heap           |
| jvm\_maxNewSize           |                                    | Depends on the configured heap           |
| jvm\_concurrentGCThreads  | Depends on the available CPU cores | Depends on the available CPU cores       |
| jvm\_parallelGCThreads    | Depends on the available CPU cores | Depends on the available CPU cores       |
| jvm\_compilation\_threads | Depends on the available CPU cores | Depends on the available CPU cores       |

## Constraints

The following tables show a list of constraints that may be required in the definition of the study, depending on the tuned parameters:

| Formula                                                    | Notes |
| ---------------------------------------------------------- | ----- |
| jvm.jvm\_minHeapSize <= jvm.jvm\_maxHeapSize               |       |
| jvm.jvm\_minHeapFreeRatio <= jvm.jvm\_maxHeapFreeRatio     |       |
| jvm.jvm\_maxNewSize < jvm.jvm\_maxHeapSize                 |       |
| jvm.jvm\_concurrentGCThreads <= jvm.jvm\_parallelGCThreads |       |
