RFR: 8273112: -Xloggc:<filename> should override -verbose:gc

Xiaowei Lu github.com+39413832+weixlu at openjdk.java.net
Fri Sep 3 02:49:00 UTC 2021


On Thu, 2 Sep 2021 03:53:06 GMT, Ioi Lam <iklam 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.
>
>> @iklam Yes, the introduction of UL has reconstructed many codes about logging. But a lot of Java users, as far as we know, are quite confused about the not working of such overrides for many days. These users have just upgraded to new java versions from java8 under our persuasion and they are more familiar with the behavior in java8. So I guess the ability to override may be useful for them.
> 
> If that's the case, those users aren't using -Xlog:gc yet. Maybe we should implement strictly what the man page says: if `-Xloggc:<filename>` is used, then `-verbose` (or `-verbose:gc`) will not cause gc logs to be printed to the stdout.
> 
> We shouldn't do anything to the other components of `-verbose`, and we shouldn't consider the interaction between `-Xlog` and `-verbose`.

@iklam @dholmes-ora Thanks for your review and helpful suggestions. Could you please sponsor this change?

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

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


More information about the hotspot-runtime-dev mailing list