RFR: 8357828: Add a timestamp to jcmd diagnostic commands [v4]
Kevin Walls
kevinw at openjdk.org
Fri Jan 23 11:14:20 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
Thanks Thomas yes it's kind of bikeshedding, but worth talking about hopefully. 8-)
Glad you agree with the simplicity part. But you like the timestamp coming from the JVM:
> The time may run differently on the jcmd side (e.g. target runs on a container on Windows or MacOS, or if we ever add remote capabilities to jcmd)
We don't want to do anything which prohibits possible future features, but also don't want to be constrained by what might possibly happen. 8-)
So you're on the same hardware, running jcmd that may contact a container. jcmd logs the time. Is the time in the container that different? The new info contains the TZ/offset I think.
We also have DiagnosticCommandMBean for remove invokation. Keeping this timestamp on the client side means we don't need a project to look into what could happen there.
> adding it to the hotspot will automatically work for every version of jcmd
Yes, this works both ways. The new jcmd will give timestamps when talking to older VMs. You can opt-in to new behaviour by choosing a later jcmd, without a JDK update in the app.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/27368#issuecomment-3789758234
More information about the hotspot-runtime-dev
mailing list