RFR: 8244190: JFR: When starting a JVM with -XX:StartFlightRecording, output is written to stdout

Erik Gahlin egahlin at openjdk.java.net
Mon Apr 12 11:35:23 UTC 2021


Hi,

Could I have review of a change that makes it possible to silence the output of JFR during startup. That is:

"Started recording 1. No limit specified, using maxsize=250MB as default.

Use jcmd 38045 JFR.dump name=1 filename=FILEPATH to copy recording data to file"

There are severals ways to approach this:

1) Remove the output completely
- Con: Users will think JFR is not working since they are used to see the output
- Con: The PID must be found by other means
- Con: No hint about jcmd, or disk space being used

2) Introduce a flag to silence the output, i.e. -XX:StartFlightRecording:silent=true
- Con: Users must read documentation to find out about the option
- Con: It introduces a second mechanism to control logging
- Pro: Easy to backport. No behavioral change.

3) Write to unified logging with level Info
- Con: Users will think JFR is not working since they are used to see the output
- Con: The PID must be found by other means
- Con: No hint about jcmd, or disk space being used
- Con: Users must read documentation to find out about -Xlog:jfr+startup=info

4) Write to unified logging with level Warning
- Con: Confusing since it is not a warning.
- Pro: Users can see the tag set and turn it off easily using -Xlog:jfr+startup=off/error

5) If -XX:StartFlightRecording has been specified, set jfr+startup=Info temporarily and write with level Info.
- Con: If user has specified -Xlog:jfr+startup=warning it will not take effect.
- Pro: Users can see the tag set and turn it off easily using -Xlog:jfr+startup=off/error

One could try to detect if the user has set the level to  jfr+startup=warning and not change the level to Info in those cases. Unfortunately there is no mechanism in UL to see if a tag set has been touched and one would need to take into account there could be several types of output, i.e. files, that can be touched. It becomes complicated.

I have chosen to implement 5. It's not perfect, but perhaps sufficient for now? Detection of -Xlog:jfr+startup=warning could be added in the future if there is a need.

$ java -XX:StartFlightRecording -version
[0.385s][info][jfr,startup] Started recording 1. No limit specified, using maxsize=250MB as default.
[0.385s][info][jfr,startup] 
[0.385s][info][jfr,startup] Use jcmd 7469 JFR.dump name=1 filename=FILEPATH to copy recording data to file.

$ java -XX:StartFlightRecording:settings=foo.bar -version
[0.174s][error][jfr,startup] Could not parse settings file 'foo.bar'

Testing: jdk/jdk/jfr, tier1-tier4

Thanks
Erik

-------------

Commit messages:
 - Remove unused imports and consistent line endings
 - Suppress JFR startup message to avoid test failure due to log decoration indentation
 - Updated test
 - Add test + minor changes
 - Initial

Changes: https://git.openjdk.java.net/jdk/pull/3417/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3417&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8244190
  Stats: 192 lines in 13 files changed: 137 ins; 11 del; 44 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3417.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3417/head:pull/3417

PR: https://git.openjdk.java.net/jdk/pull/3417


More information about the hotspot-jfr-dev mailing list