On Tue, 20 Jan 2026 08:57:52 GMT, Ivan Bereziuk <[email protected]> wrote:
>> `jcmd` provides great diagnostics but many commands lack a timestamp in >> their output. >> Adding a timestamp to the output of some would add value for those debugging >> JVM data. >> >> Some diagnostic commands already provide timestamps. For example >> `Thread.print` already prints one of "yyyy-MM-dd HH:mm:ss" format. >> >> With this MR I propose to introduce time-stamping to all diagnostic `jcmd` >> commands in a form of an additional common flag "-T": >> >> jcmd [pid | main-class] [-T] command... | PerfCounter.print | -f filename >> ^^^^ >> >> * The choice for time format is "yyyy-MM-dd HH:mm:ss" as it is already used >> in `Thread.print`. >> * `Thread.print` prints timestamp irrespectively from "-T" flag presence to >> preserve backwards compatibility. >> >> I haven't added a timestamp to the following diagnostic command: >> * `VM.uptime` - command run with `-date` argument will also print a >> timestamp; >> * `VM.system_properties` - as the output already lists a timestamp. Not sure >> if we need more timestamps here. >> * `Thread.dump_to_file` - the content dumped to a file already has a >> timestamp; > > Ivan Bereziuk has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase. The pull request contains 15 additional > commits since the last revision: > > - remove TimeStamp::No as it's not used. virtual should be flipped to > override in bulk (afressed clang warning) > - Merge branch 'master' into 8357828_add_timestamp_to_jcmd > - changes to jcmd.md > - undo changes to reorder_help_cmd() > - cleanup > - add timestamp to VM.version. Add test > - updated jcmd usage text > - undo the changes to the modified earlier tests as timestamp presence is > fully backwards compatible > - introduce -T as a commong flag > - Merge branch 'master' into 8357828_add_timestamp_to_jcmd > - ... and 5 more: https://git.openjdk.org/jdk/compare/e1bc2481...5f1cefe0 I've made timestamping optional with "-T" flag. The flag is part of the command sent to the target JVM. jcmd [pid | main-class] [-T] command... | PerfCounter.print | -f filename ^^^^ The target diagnostic command handler can decide how to act on it. @dholmes-ora > ... what form should this timestamp take? Shouldn't it be configurable to > allow matching with what may be presented by Unified Logging e.g. VM uptime > rather than wall-clock time? > And rather than add timestamp printing code to each dcmd it would make more > sense to me to have a global dcmd flag that says "print a timestamp" (with a > given format). `Thread.print` already prints a timestamp, hence explicit "-T" has no effect for this particular command. This also affected my choice for using format "yyyy-MM-dd HH:mm:ss". At least as a default. Do you think we need to be able changing the timestamp format (say "-T=UTC")? Should we add time-stamping to STDOUT from commands that are of "action" type? E.g. "GC.run". ------------- PR Comment: https://git.openjdk.org/jdk/pull/27368#issuecomment-3772022851
