RFR: 8273112: -Xloggc and -Xlog should override -verbose

Ioi Lam iklam at openjdk.java.net
Wed Sep 1 16:42:32 UTC 2021


On Wed, 1 Sep 2021 07:50:18 GMT, Xiaowei Lu <github.com+39413832+weixlu at openjdk.org> wrote:

> > I find it very unfortunate that it states that `-verbose:gc` will be overridden by `-Xloggc:<filename>` and `-Xlog` as that makes the logic for dealing with this GC case very convoluted. It would make much more sense that `-verbose:x` simply be treated as its corresponding `-Xlog` variant. Then we would need no special logic at all.
> 
> Things are quite easy if `-verbose:x` is treated as `-Xlog`. Multiple -Xlog arguments for the same output override each other in their given order, according to https://docs.oracle.com/en/java/javase/16/docs/specs/man/java.html.
> 
> > I'm unclear how the non-GC versions of `-verbose:x` are treated with respect to explicit `-Xlog:x` commands?
> 
> I have looked up some documents but unfortunately haven't found relevant statements.

History:

See https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html

Before UL was implemented, we had this:

" -Xloggc:filename -- Sets the file to which verbose GC events information should be redirected for logging. The information written to this file is similar to the output of -verbose:gc with the time elapsed since the first GC event preceding each logged event. The -Xloggc option overrides -verbose:gc if both are given with the same java command."



~/jdk/official/jdk8_b132/linux_amd64$ ./bin/java -verbose:gc -cp ~/tmp HelloGC
[GC (System.gc())  391K->536K(1029632K), 0.0243973 secs]
[Full GC (System.gc())  536K->259K(1029632K), 0.0079780 secs]
~/jdk/official/jdk8_b132/linux_amd64$ ./bin/java -Xloggc:foo -verbose:gc -cp ~/tmp HelloGC
~/jdk/official/jdk8_b132/linux_amd64$ ./bin/java -verbose:gc -Xloggc:foo -cp ~/tmp HelloGC
~/jdk/official/jdk8_b132/linux_amd64$ 


After UL was implemented, we changed the man page to say this, but unfortunately the "overrides" part is no longer working:

"Sets the file to which verbose GC events information should be redirected for logging. The -Xloggc option overrides -verbose:gc if both are given with the same java command. -Xloggc:filename is replaced by -Xlog:gc:filename. See Enable Logging with the JVM Unified Logging Framework."

****************************
UL doesn't support the notion of "overriding" as required by the java8 man page. If -Xlog:gc is specified for both a file and stdout, both will be written:


$ rm foo
$ tbjava -Xlog:gc:file=foo -Xlog:gc:stdout -version
[0.003s][info][gc] Using G1
java version "18-internal" 2022-03-15
Java(TM) SE Runtime Environment (build 18-internal+0-adhoc.iklam.open)
Java HotSpot(TM) 64-Bit Server VM (build 18-internal+0-adhoc.iklam.open, mixed mode, sharing)
$ cat foo 
[0.003s][info][gc] Using G1
$ rm foo
$ tbjava -Xlog:gc:stdout -Xlog:gc:file=foo -version
[0.003s][info][gc] Using G1
java version "18-internal" 2022-03-15
Java(TM) SE Runtime Environment (build 18-internal+0-adhoc.iklam.open)
Java HotSpot(TM) 64-Bit Server VM (build 18-internal+0-adhoc.iklam.open, mixed mode, sharing)
$ cat foo 
[0.003s][info][gc] Using G1
$ 


I think the ability to "override" -verbose:gc with -Xloggc:filename is rather useless. We should just change the man page to match the current behavior (i.e., -verbose:gc is an alias to -Xlog:gc:stdout) and remove the mention of overriding. If someone really wants the old behavior, they should remove -verbose:gc from their command-line.

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

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


More information about the hotspot-runtime-dev mailing list