RFR: 8357828: Add a timestamp to jcmd diagnostic commands [v4]
Ivan Bereziuk
duke at openjdk.org
Fri Jan 23 15:02:09 UTC 2026
On Thu, 22 Jan 2026 11:11:04 GMT, Ivan Bereziuk <duke at openjdk.org> wrote:
>> `jcmd` provides great diagnostics but many commands lack a timestamp in their output.
>> Adding a timestamp to the output 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 ISO 8601 `yyyy-MM-dd'T'HH:mm:ss.SSSZ` (example `2026-01-21T16:58:49.518+0100`)
>> * if "-t" flag is not passed, `Thread.print` keeps printing "yyyy-MM-dd HH:mm:ss" timestamp to preserve backwards compatibility.
>
> Ivan Bereziuk has updated the pull request incrementally with one additional commit since the last revision:
>
> change flag name from -T to -t
Kevin, Thomas, thank you very much for comments.
Indeed. The way `jcmd` is implemented currently and in older JDKs, the tool does not question arguments following PID.
One more thing to keep in mind.
The is a use case with a chain of commands passed to `jcmd`. With this MR we can timestamp per command:
$ cat input.txt
-t VM.version
-t VM.version
$ jcmd <PID> -f input.txt
51721:
2026-01-23T14:58:28.515+0100
Java HotSpot(TM) 64-Bit Server VM version 27-internal-john24.open
JDK 27.0.0
2026-01-23T14:58:28.518+0100
Java HotSpot(TM) 64-Bit Server VM version 27-internal-john24.open
JDK 27.0.0
The timestamping implemented in `JCmd.java` would print timestamp only once at the beginning.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27368#issuecomment-3790630542
More information about the hotspot-runtime-dev
mailing list