RFR: 8357828: Add a timestamp to jcmd diagnostic commands [v3]
Ivan Bereziuk
duke at openjdk.org
Wed Jan 21 16:28:15 UTC 2026
> `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 incrementally with two additional commits since the last revision:
- improve test. Assert new ISO 8601 format
- handle timestamp in parse_and_execute(). Thread.print is exceptional. Add default initialation to JcmdOptions
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/27368/files
- new: https://git.openjdk.org/jdk/pull/27368/files/5f1cefe0..c702901d
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=27368&range=02
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=27368&range=01-02
Stats: 133 lines in 4 files changed: 19 ins; 101 del; 13 mod
Patch: https://git.openjdk.org/jdk/pull/27368.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27368/head:pull/27368
PR: https://git.openjdk.org/jdk/pull/27368
More information about the hotspot-runtime-dev
mailing list