RFR: 8357828: Add a timestamp to jcmd diagnostic commands [v4]
Kevin Walls
kevinw at openjdk.org
Thu Jan 22 12:36:02 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
I am liking the much simpler alternative. I think you did a lot of exploratory work here, but there is a lot of complexity needed just because Thread.print already prints a timestamp. I do not find this ugly or unparseable:
$ jcmd -t 2970459 Thread.print
2970459:
2026-01-22T12:05:50.518+0100
2026-01-22 12:05:55
Full thread dump Java HotSpot(TM) 64-Bit Server VM (27-internal-kwalls.open mixed mode, sharing)
JDK version: Java(TM) SE Runtime Environment (27.0) (fastdebug build 27-internal-kwalls.open)
Threads class SMR info: ...
It would not seem right to add the common flags infrastructure in dcmd framework just in case it's useful in future, just add what we need right now.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27368#issuecomment-3784154369
More information about the hotspot-runtime-dev
mailing list