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

native-image, UX, JFR, -XX:StartFlightRecording flags/arguments units are not aligned with HotSpot convention #3638

Closed
Karm opened this issue Jul 30, 2021 · 1 comment · Fixed by #3639
Assignees

Comments

@Karm
Copy link
Contributor

Karm commented Jul 30, 2021

e.g. maxsize is parsed as a plain Long, see: JfrManager.java whereas in HotSpot, one can use units, see jfrOptionSet.cpp.

How to reproduce:

  1. Build
$ export JAVA_HOME=/home/karm/X/JDKs/graalvm-ce-java11-21.2.0/;export PATH=${JAVA_HOME}/bin:${PATH}
$ native-image --version
GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08)
$ cat Main.java
public class Main {
    public static void main(String... args) {
        System.out.println("Meh.");
    }
}
$ javac Main.java
$ native-image -H:+AllowVMInspection Main
  1. Run setting maxsize with plain number of bytes. Works fine. ✔️
$ java -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10485760,filename=flight-java.jfr Main
Started recording 1.

Use jcmd 273484 JFR.dump name=1 to copy recording data to file.
Meh.

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10485760,filename=flight-native.jfr
Meh.
  1. Try to use units with maxsize attribute. Crashes with native image run ❌
$ java -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-java.jfr Main
Started recording 1.

Use jcmd 273654 JFR.dump name=1 to copy recording data to file.
Meh.

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-native.jfr
Exception in thread "main" com.oracle.svm.core.util.UserError$UserException: Could not parse JFR argument 'maxsize=10M'. Expected a number.
	at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
	at com.oracle.svm.jfr.JfrManager.parseLong(JfrManager.java:171)
	at com.oracle.svm.jfr.JfrManager.initRecording(JfrManager.java:107)
	at com.oracle.svm.jfr.JfrManager.setup(JfrManager.java:72)
	at com.oracle.svm.core.jdk.RuntimeSupport.executeHooks(RuntimeSupport.java:125)
	at com.oracle.svm.core.jdk.RuntimeSupport.executeStartupHooks(RuntimeSupport.java:75)

TODO: Align options parsing flows so as users can use the same with both setups.

OS

Linux  4.18.0-240.22.1.el8_3.x86_64 (Centos 8 Stream)
@munishchouhan
Copy link
Contributor

@Karm thanks for the contribution, we will check it out and get back to you

zakkak pushed a commit to zakkak/mandrel that referenced this issue Aug 17, 2021
Fixes oracle#3638

Example:

Unpatched
---------

```
$ export JAVA_HOME=/home/karm/X/JDKs/graalvm-ce-java11-21.2.0/;export PATH=${JAVA_HOME}/bin:${PATH}

$ native-image --version
GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08)

$ javac Main.java

$ native-image -H:+AllowVMInspection Main

$ java -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-java.jfr -Xlog:jfr Main
[0.279s][info][jfr] Flight Recorder initialized
[0.279s][info][jfr] Created repository /tmp/2021_07_30_15_11_00_295289
[0.309s][info][jfr] Creating thread sampler for java:20 ms, native 0 ms
[0.309s][info][jfr] Enrolling thread sampler
[0.309s][info][jfr] Enrolling thread sampler
[0.309s][info][jfr] Updated thread sampler for java: 20  ms, native 0 ms
[0.309s][info][jfr] Updated thread sampler for java: 20  ms, native 0 ms
[0.309s][info][jfr] Updated thread sampler for java: 20  ms, native 20 ms
[0.322s][info][jfr] Started recording "1" (1) {maxsize=10.0MB, dumponexit=true, filename=/tmp/rep/flight-java.jfr}
Started recording 1.
Use jcmd 295289 JFR.dump name=1 to copy recording data to file.
Meh.
[0.343s][info][jfr] Updated thread sampler for java: 0  ms, native 20 ms
[0.344s][info][jfr] Disenrolling thread sampler
[0.344s][info][jfr] Stopped recording "1" (1). Reason "Dump on exit".
[0.382s][info][jfr] Wrote recording "1" (1) to /tmp/rep/flight-java.jfr
[0.382s][info][jfr] Closed recording "1" (1)
[0.383s][info][jfr] Removed repository /tmp/2021_07_30_15_11_00_295289

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
Exception in thread "main" com.oracle.svm.core.util.UserError$UserException: Could not parse JFR argument 'maxsize=10M'. Expected a number.
    at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
    at com.oracle.svm.jfr.JfrManager.parseLong(JfrManager.java:171)
    at com.oracle.svm.jfr.JfrManager.initRecording(JfrManager.java:107)
    at com.oracle.svm.jfr.JfrManager.setup(JfrManager.java:72)
    at com.oracle.svm.core.jdk.RuntimeSupport.executeHooks(RuntimeSupport.java:125)
    at com.oracle.svm.core.jdk.RuntimeSupport.executeStartupHooks(RuntimeSupport.java:75)
```

Patched
-------

```
$ export JAVA_HOME=/home/karm/tmp/mandrel-java11-21.3-SNAPSHOT/;export PATH=${JAVA_HOME}/bin:${PATH}

$ native-image --version
native-image 21.3.0-deveab4c4ec5cb5 Mandrel Distribution (Java Version 11.0.12+7)

$ native-image -H:+AllowVMInspection Main

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_13_28_295949
[info][jfr] Started recording "1" (1) {maxsize=10.0MB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10m,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_13_55_296117
[info][jfr] Started recording "1" (1) {maxsize=10.0MB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10k,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_14_00_296178
[info][jfr] Started recording "1" (1) {maxsize=10.0kB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10K,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_14_05_296238
[info][jfr] Started recording "1" (1) {maxsize=10.0kB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10g,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_14_11_296302
[info][jfr] Started recording "1" (1) {maxsize=10.0GB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10G,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_16_04_296529
[info][jfr] Started recording "1" (1) {maxsize=10.0GB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>
```

Signed-off-by: Michal Karm Babacek <karm@redhat.com>
zakkak pushed a commit to graalvm/mandrel that referenced this issue Aug 19, 2021
Fixes oracle#3638

Example:

Unpatched
---------

```
$ export JAVA_HOME=/home/karm/X/JDKs/graalvm-ce-java11-21.2.0/;export PATH=${JAVA_HOME}/bin:${PATH}

$ native-image --version
GraalVM 21.2.0 Java 11 CE (Java Version 11.0.12+6-jvmci-21.2-b08)

$ javac Main.java

$ native-image -H:+AllowVMInspection Main

$ java -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-java.jfr -Xlog:jfr Main
[0.279s][info][jfr] Flight Recorder initialized
[0.279s][info][jfr] Created repository /tmp/2021_07_30_15_11_00_295289
[0.309s][info][jfr] Creating thread sampler for java:20 ms, native 0 ms
[0.309s][info][jfr] Enrolling thread sampler
[0.309s][info][jfr] Enrolling thread sampler
[0.309s][info][jfr] Updated thread sampler for java: 20  ms, native 0 ms
[0.309s][info][jfr] Updated thread sampler for java: 20  ms, native 0 ms
[0.309s][info][jfr] Updated thread sampler for java: 20  ms, native 20 ms
[0.322s][info][jfr] Started recording "1" (1) {maxsize=10.0MB, dumponexit=true, filename=/tmp/rep/flight-java.jfr}
Started recording 1.
Use jcmd 295289 JFR.dump name=1 to copy recording data to file.
Meh.
[0.343s][info][jfr] Updated thread sampler for java: 0  ms, native 20 ms
[0.344s][info][jfr] Disenrolling thread sampler
[0.344s][info][jfr] Stopped recording "1" (1). Reason "Dump on exit".
[0.382s][info][jfr] Wrote recording "1" (1) to /tmp/rep/flight-java.jfr
[0.382s][info][jfr] Closed recording "1" (1)
[0.383s][info][jfr] Removed repository /tmp/2021_07_30_15_11_00_295289

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
Exception in thread "main" com.oracle.svm.core.util.UserError$UserException: Could not parse JFR argument 'maxsize=10M'. Expected a number.
    at com.oracle.svm.core.util.UserError.abort(UserError.java:68)
    at com.oracle.svm.jfr.JfrManager.parseLong(JfrManager.java:171)
    at com.oracle.svm.jfr.JfrManager.initRecording(JfrManager.java:107)
    at com.oracle.svm.jfr.JfrManager.setup(JfrManager.java:72)
    at com.oracle.svm.core.jdk.RuntimeSupport.executeHooks(RuntimeSupport.java:125)
    at com.oracle.svm.core.jdk.RuntimeSupport.executeStartupHooks(RuntimeSupport.java:75)
```

Patched
-------

```
$ export JAVA_HOME=/home/karm/tmp/mandrel-java11-21.3-SNAPSHOT/;export PATH=${JAVA_HOME}/bin:${PATH}

$ native-image --version
native-image 21.3.0-deveab4c4ec5cb5 Mandrel Distribution (Java Version 11.0.12+7)

$ native-image -H:+AllowVMInspection Main

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10M,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_13_28_295949
[info][jfr] Started recording "1" (1) {maxsize=10.0MB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10m,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_13_55_296117
[info][jfr] Started recording "1" (1) {maxsize=10.0MB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10k,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_14_00_296178
[info][jfr] Started recording "1" (1) {maxsize=10.0kB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10K,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_14_05_296238
[info][jfr] Started recording "1" (1) {maxsize=10.0kB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10g,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_14_11_296302
[info][jfr] Started recording "1" (1) {maxsize=10.0GB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>

$ ./main -XX:+FlightRecorder -XX:StartFlightRecording=maxsize=10G,filename=flight-native.jfr -XX:FlightRecorderLogging=jfr
[info][jfr] Flight Recorder initialized
[info][jfr] Created repository /tmp/2021_07_30_15_16_04_296529
[info][jfr] Started recording "1" (1) {maxsize=10.0GB, dumponexit=true, filename=/tmp/rep/flight-native.jfr}
Meh.
<removed for brevity>
```

Signed-off-by: Michal Karm Babacek <karm@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants