Skip to content

Commit bfdb591

Browse files
committed
Merge tag 'v0.17.0' into jdk-21+24-mmtk-merge
2 parents c79eea6 + ffbdbed commit bfdb591

19 files changed

+446
-150
lines changed

.github/scripts/ci-checkout.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ set -ex
33

44
. $(dirname "$0")/common.sh
55

6-
OPENJDK_URL=`cargo read-manifest --manifest-path=$BINDING_PATH/mmtk/Cargo.toml | python -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["openjdk"]["openjdk_repo"])'`
7-
OPENJDK_VERSION=`cargo read-manifest --manifest-path=$BINDING_PATH/mmtk/Cargo.toml | python -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["openjdk"]["openjdk_version"])'`
6+
OPENJDK_URL=`cargo read-manifest --manifest-path=$BINDING_PATH/mmtk/Cargo.toml | python3 -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["openjdk"]["openjdk_repo"])'`
7+
OPENJDK_VERSION=`cargo read-manifest --manifest-path=$BINDING_PATH/mmtk/Cargo.toml | python3 -c 'import json,sys; print(json.load(sys.stdin)["metadata"]["openjdk"]["openjdk_version"])'`
88

99
rm -rf $OPENJDK_PATH
1010
git clone $OPENJDK_URL $OPENJDK_PATH

.github/scripts/ci-test-only-normal.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHea
2323
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar hsqldb
2424
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar eclipse
2525

26+
# Test heap resizing
27+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms20M -Xmx100M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar fop
28+
2629
# --- Immix ---
2730
export MMTK_PLAN=Immix
2831

@@ -41,6 +44,9 @@ build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHea
4144
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar hsqldb
4245
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar eclipse
4346

47+
# Test heap resizing
48+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms20M -Xmx100M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar fop
49+
4450
# --- Immix ---
4551
export MMTK_PLAN=GenImmix
4652

@@ -59,6 +65,9 @@ build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHea
5965
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar hsqldb
6066
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms500M -Xmx500M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar eclipse
6167

68+
# Test heap resizing
69+
build/linux-x86_64-normal-server-$DEBUG_LEVEL/jdk/bin/java -XX:+UseThirdPartyHeap -server -XX:MetaspaceSize=100M -Xms20M -Xmx100M -jar $DACAPO_PATH/dacapo-2006-10-MR2.jar fop
70+
6271
# --- GenCopy ---
6372
export MMTK_PLAN=GenCopy
6473

.github/scripts/pgo-build.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Compile with profiling support
4+
RUSTFLAGS="-Cprofile-generate=/tmp/$USER/pgo-data" make CONF=linux-x86_64-normal-server-release THIRD_PARTY_HEAP=$PWD/../mmtk-openjdk/openjdk images
5+
6+
# Remove extraneous profiling data
7+
rm -rf /tmp/$USER/pgo-data/*
8+
9+
# Profile using fop
10+
MMTK_PLAN=GenImmix MMTK_STRESS_FACTOR=4194304 MMTK_PRECISE_STRESS=false ./build/linux-x86_64-normal-server-release/images/jdk/bin/java -XX:MetaspaceSize=500M -XX:+DisableExplicitGC -XX:-TieredCompilation -Xcomp -XX:+UseThirdPartyHeap -Xms60M -Xmx60M -jar /usr/share/benchmarks/dacapo/dacapo-evaluation-git-6e411f33.jar -n 5 fop
11+
12+
# Merge profiling data
13+
/opt/rust/toolchains/1.66.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o /tmp/$USER/pgo-data/merged.profdata /tmp/$USER/pgo-data
14+
15+
# Compile using profiling data
16+
RUSTFLAGS="-Cprofile-use=/tmp/$USER/pgo-data/merged.profdata -Cllvm-args=-pgo-warn-missing-function" make CONF=linux-x86_64-normal-server-release THIRD_PARTY_HEAP=$PWD/../mmtk-openjdk/openjdk images

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
0.17.0 (2023-02-17)
2+
===
3+
4+
* MMTk OpenJDK binding now uses Rust 1.66.1 and MSRV is 1.61.0.
5+
* Support dynamic heap resizing (enabled when `Xmx` and `Xms` values are different).
6+
* Remove all inline directives. We rely on Rust compiler and PGO for inline decisions. Add provide a PGO guide.
7+
* Fix a crash caused by null pointer access if the VM calls `CollectedHeap::soft_ref_policy()`.
8+
* Update to mmtk-core 0.17.0.
9+
110
0.16.0 (2022-12-06)
211
===
312

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Please make sure your dev machine satisfies those prerequisites.
1515

1616
### Before you continue
1717

18-
The minimal supported Rust version for MMTk-OpenJDK binding is 1.57.0. Make sure your Rust version is higher than this. We test MMTk-OpenJDK
19-
binding with Rust 1.59.0 (as specified in [`rust-toolchain`](mmtk/rust-toolchain)).
18+
The minimal supported Rust version for MMTk-OpenJDK binding is 1.61.0. Make sure your Rust version is higher than this. We test MMTk-OpenJDK
19+
binding with Rust 1.66.1 (as specified in [`rust-toolchain`](mmtk/rust-toolchain)).
2020
You may also need to use ssh-agent to authenticate with github (see [here](https://github.com/rust-lang/cargo/issues/3487) for more info):
2121

2222
```console
@@ -126,6 +126,67 @@ $ make CONF=linux-x86_64-normal-server-release THIRD_PARTY_HEAP=$PWD/../mmtk-ope
126126

127127
The output jdk is then found at `./build/linux-x86_64-normal-server-release/images/jdk`.
128128

129+
### Profile-Guided Optimized Build
130+
131+
In order to get the best performance, we recommend using a profile-guided
132+
optimized (PGO) build. Rust supports [PGO
133+
builds](https://doc.rust-lang.org/rustc/profile-guided-optimization.html) by
134+
directly hooking into the LLVM profiling infrastructure. In order to have the
135+
correct LLVM tools version, you should install the relevant `llvm-tools-preview`
136+
component using `rustup`:
137+
138+
```console
139+
$ rustup component add llvm-tools-preview
140+
```
141+
142+
In this example, we focus on the DaCapo benchmarks and the `GenImmix`
143+
collector. For best results, it is recommended to profile the workload you are
144+
interested in measuring. We use `fop` as it is a relatively small benchmark but
145+
also exercises the GC. In order to best tune our GC performance, we use a
146+
stress factor of 4 MB in order to trigger more GC events.
147+
148+
First we compile MMTk with profiling support:
149+
150+
```console
151+
$ RUSTFLAGS="-Cprofile-generate=/tmp/$USER/pgo-data" make CONF=linux-x86_64-normal-server-release THIRD_PARTY_HEAP=$PWD/../mmtk-openjdk/openjdk images
152+
$ rm -rf /tmp/$USER/pgo-data/*
153+
```
154+
We clear the `/tmp/$USER/pgo-data` directory as during compilation, the JVM we
155+
have created is used in a bootstrap process, resulting in profile data being
156+
emitted.
157+
158+
We then run `fop` in order to get some profiling data. Note that your location
159+
for the DaCapo benchmarks may be different:
160+
161+
```bash
162+
MMTK_PLAN=GenImmix MMTK_STRESS_FACTOR=4194304 MMTK_PRECISE_STRESS=false ./build/linux-x86_64-normal-server-release/images/jdk/bin/java -XX:MetaspaceSize=500M -XX:+DisableExplicitGC -XX:-TieredCompilation -Xcomp -XX:+UseThirdPartyHeap -Xms60M -Xmx60M -jar /usr/share/benchmarks/dacapo/dacapo-evaluation-git-6e411f33.jar -n 5 fop
163+
```
164+
165+
We have to merge the profiling data into something we can feed into the Rust
166+
compiler using `llvm-profdata`:
167+
168+
```console
169+
$ /opt/rust/toolchains/1.66.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/llvm-profdata merge -o /tmp/$USER/pgo-data/merged.profdata /tmp/$USER/pgo-data
170+
```
171+
172+
The location of your version of `llvm-profdata` may be different to what we
173+
have above. *Make sure to only use a version of `llvm-profdata` that matches
174+
your Rust version.*
175+
176+
Finally, we build a new image using the profiling data as an input:
177+
178+
```console
179+
$ RUSTFLAGS="-Cprofile-use=/tmp/$USER/pgo-data/merged.profdata -Cllvm-args=-pgo-warn-missing-function" make CONF=linux-x86_64-normal-server-release THIRD_PARTY_HEAP=$PWD/../mmtk-openjdk/openjdk images
180+
```
181+
182+
We now have an OpenJDK build under
183+
`./build/linux-x86_64-normal-server-release/images/jdk` with MMTk that has been
184+
optimized using PGO.
185+
186+
For ease of use, we have provided an example script which does the above in
187+
`.github/scripts/pgo-build.sh` that you may adapt for your purposes. Note that
188+
you may have to change the location of `llvm-profdata`.
189+
129190
### Location of Mark-bit
130191
The location of the mark-bit can be specified by the environment variable
131192
`MARK_IN_HEADER`. By default, the mark-bit is located on the side (in a side

0 commit comments

Comments
 (0)