Optimizing a sample Java OpenJ9 application
In this example study we’ll tune the parameters of PageRank, one of the benchmarks available in the Renaissance suite, with the goal of minimizing its memory usage. Application monitoring is provided by Prometheus, leveraging a JMX exporter.
The test environment includes the following instances:
- Akamas: instance running Akamas
- PageRank: instance running the PageRank benchmark and the Prometheus monitoring service
To gather metrics about PageRank we will use a Prometheus and a JMX exporter. Here’s the scraper to add to the Prometheus configuration to extract the metrics from the exporter:
1
- job_name: jmx-exporter
2
static_configs:
3
- targets: ['pagerank.akamas.io:5556']
4
labels:
5
instance: jvm
To run and monitor the benchmark we’ll require on the PageRank instance:
Here’s the snippet of code to configure the instance as required for this guide:
mkdir renaissance; cd renaissance
wget -O renaissance.jar https://github.com/renaissance-benchmarks/renaissance/releases/download/v0.10.0/renaissance-gpl-0.10.0.jar
wget -O jmx_exporter.jar https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.14.0/jmx_prometheus_javaagent-0.14.0.jar
echo -e '--\nwhitelistObjectNames: ["java.lang:*"]' > conf.yaml
In this section, we will guide you through the steps required to set up the optimization on Akamas.
If you have not installed the Eclipse OpenJ9 optimization pack yet, take a look at the optimization pack page Eclipse OpenJ9 to proceed with the installation.
Here’s the definition of the system we will use to group our components and telemetry-instances for this example:
1
name: pagerank
2
description: A system to tune the pagerank benchmark
To create the system run the following command:
akamas create system pagerank.yaml
We’ll use a component of type IBM J9 VM 8 to represent the JVM underlying the PageRank benchmark. To identify the JMX-related metrics in Prometheus the configuration requires the
prometheus
property for the telemetry service, detailed later in this guide.Here’s the definition of the component:
1
name: jvm
2
componentType: java-ibm-j9vm-8
3
properties:
4
prometheus:
5
instance: jvm
6
job: jmx-exporter
To create the component in the system run the following command:
akamas create component jvm.yaml pagerank
The workflow used for this study consists of two main stages:
- generate the configuration file containing the tested OpenJ9 parameters
- run the execution using previously written parameters
Here’s the definition of the workflow:
name: run-pagerank
tasks:
- name: Configure parameters
operator: FileConfigurator
arguments:
source:
hostname: pagerank.akamas.io
username: ubuntu
path: /home/ubuntu/renaissance/j9_opts.template
key: key
target:
hostname: pagerank.akamas.io
username: ubuntu
path: /home/ubuntu/renaissance/j9_opts
key: key
- name: Run benchmark
operator: Executor
arguments:
command: "cd renaissance; java -javaagent:./jmx_exporter.jar=5556:conf.yaml $(cat j9_opts) -jar renaissance.jar -r 2 page-rank"
host:
hostname: pagerank.akamas.io
username: ubuntu
key: key
Where the configuration template is
j9_opts.template
is defined as follows:1
${jvm.j9vm_gcPolicy} ${jvm.j9vm_maxHeapSize} ${jvm.j9vm_newSpaceFixed} ${jvm.j9vm_minFreeHeap} ${jvm.j9vm_maxFreeHeap} ${jvm.j9vm_gcThreads}
To create the workflow run the following command:
akamas create workflow workflow.yaml
The following is the definition of the telemetry instance that fetches metrics from the Prometheus service:
1
provider: Prometheus
2
config:
3
address: pagerank.akamas.io
4
port: 9090
To create the telemetry instance in the system run the following command:
akamas create telemetry-instance prometheus.yaml pagerank
This telemetry instance will be able to bind the fetched metrics to the related jvm component thanks to the
prometheus
attribute we previously added in its definition.The goal of this study is to find a JVM configuration that minimizes the peak memory used by the benchmark.
The optimized parameters are the maximum heap size, the garbage collector used and several other parameters managing the new and old heap areas.
We also specify a constraint stating that the GC regions can’t exceed the total heap available, to avoid experimenting with parameter configurations that can’t start in the first place.
Here’s the definition of the study:
1
name: Optimize PageRank
2
description: Tweaking the Eclipse OpenJ9 parameters to optimize the page-rank benchmark.
3
system: pagerank
4
workflow: run-pagerank
5
6
goal:
7
objective: minimize
8
function:
9
formula: max_memory
10
variables:
11
max_memory:
12
metric: jvm.jvm_memory_used
13
aggregation: max
14
15
parametersSelection:
16
- name: jvm.j9vm_gcPolicy
17
- name: jvm.j9vm_maxHeapSize
18
domain: [1250, 2000]
19
- name: jvm.j9vm_newSpaceFixed
20
domain: [350, 2000]
21
- name: jvm.j9vm_minFreeHeap
22
- name: jvm.j9vm_maxFreeHeap
23
- name: jvm.j9vm_gcThreads
24
25
parameterConstraints:
26
- name: Max heap must always be greater than new size
27
formula: jvm.j9vm_maxHeapSize > jvm.j9vm_newSpaceFixed
28
- name: Max free always greater than min free
29
formula: jvm.j9vm_minFreeHeap + 0.05 < jvm.j9vm_maxFreeHeap
30
31
steps:
32
- name: baseline
33
type: baseline
34
values:
35
jvm.jvm_gcType: gencon
36
jvm.jvm_maxHeapSize: 2000
37
38
- name: optimize
39
type: optimize
40
numberOfExperiments: 30
To create and run the study execute the following commands:
akamas create study study.yaml
akamas start study 'Optimize PageRank'
Last modified 11d ago