Skip to content

Conversation

@iklam
Copy link
Member

@iklam iklam commented Jul 15, 2021

It's useful to print VM arguments to the log file, especially when you are logging several JVM invocations:

$ java -cp foo -Xlog:gc:file=a.log -Xcomp com.Foo
$ java -cp foo -Xlog:gc:file=b.log -Xint com.Foo

After a while, you may forget which process created a.log and which created b.log. Adding vm arguments into the log file will help distinguishing them:

$ java -cp foo -Xlog:gc,arguments:file=a.log -Xcomp com.Foo
$ java -cp foo -Xlog:gc,arguments:file=b.log -Xint com.Foo

$ grep jvm_args a.log b.log
a.log:[0.015s][info][arguments] jvm_args: -Xlog:gc,arguments:file=a.log -Xint
b.log:[0.001s][info][arguments] jvm_args: -Xlog:gc,arguments:file=b.log -Xcomp

Here's an example of what the log looks like:

$ java -Xlog:arguments -Xshare:on -cp ~/tmp -Dxx=yy -esa HelloWorld 1 2 3
[0.001s][info][arguments] VM Arguments:
[0.001s][info][arguments] jvm_args: -Xlog:arguments -Xshare:on -Dxx=yy -esa
[0.001s][info][arguments] java_command: HelloWorld 1 2 3
[0.001s][info][arguments] java_class_path (initial): /home/user/tmp
[0.001s][info][arguments] Launcher Type: SUN_STANDARD
Hello World

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8270801: Print VM arguments with java -Xlog:arguments

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4801/head:pull/4801
$ git checkout pull/4801

Update a local copy of the PR:
$ git checkout pull/4801
$ git pull https://git.openjdk.java.net/jdk pull/4801/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4801

View PR using the GUI difftool:
$ git pr show -t 4801

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4801.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 15, 2021

👋 Welcome back iklam! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jul 15, 2021

@iklam The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jul 15, 2021
@iklam iklam marked this pull request as ready for review July 15, 2021 22:57
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 15, 2021
@mlbridge
Copy link

mlbridge bot commented Jul 15, 2021

Webrevs

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ioi,

This looks good and useful. I'm surprised it hasn't been done before. :)

Thanks,
David

@openjdk
Copy link

openjdk bot commented Jul 16, 2021

@iklam This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8270801: Print VM arguments with java -Xlog:arguments

Reviewed-by: dholmes, xliu, stuefe, minqi

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 85 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 16, 2021
Copy link
Member

@navyxliu navyxliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@navyxliu
Copy link
Member

I think it better off use LogMessage to guarantee multiple-lines are not separated.
then I realize that this is very beginning, other threads haven't been up yet. so it's fine.

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful, Ioi!

@tstuefe
Copy link
Member

tstuefe commented Jul 16, 2021

Side note, I wish we had a similar option to print the pid (and not much else). In our proprietary port, we have a -XshowPid, which I use surprisingly often, even in scripts.

Copy link
Contributor

@yminqi yminqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@iklam
Copy link
Member Author

iklam commented Jul 16, 2021

Side note, I wish we had a similar option to print the pid (and not much else). In our proprietary port, we have a -XshowPid, which I use surprisingly often, even in scripts.

We have a few choices:

  • -Xlog:pid : but this seems too limited to introduce a new log tag
  • -Xlog:identifyprocess: print all relevant info that helps identifying the process. This would include both the arguments, the pid, and perhaps some other info as well (owner id, etc??).

If the second makes sense, we should think of a good tag name :-) I will hold the integration of the current PR for now.

@tstuefe
Copy link
Member

tstuefe commented Jul 17, 2021

Side note, I wish we had a similar option to print the pid (and not much else). In our proprietary port, we have a -XshowPid, which I use surprisingly often, even in scripts.

We have a few choices:

  • -Xlog:pid : but this seems too limited to introduce a new log tag
  • -Xlog:identifyprocess: print all relevant info that helps identifying the process. This would include both the arguments, the pid, and perhaps some other info as well (owner id, etc??).

If the second makes sense, we should think of a good tag name :-) I will hold the integration of the current PR for now.

After thinking about this, I think either a new "-Xlog:process", or we could just log it under "-Xlog:os". The latter could maybe benefit from some cleaning up to reduce the noise at info level.

@iklam
Copy link
Member Author

iklam commented Jul 17, 2021

Side note, I wish we had a similar option to print the pid (and not much else). In our proprietary port, we have a -XshowPid, which I use surprisingly often, even in scripts.

We have a few choices:

  • -Xlog:pid : but this seems too limited to introduce a new log tag
  • -Xlog:identifyprocess: print all relevant info that helps identifying the process. This would include both the arguments, the pid, and perhaps some other info as well (owner id, etc??).

If the second makes sense, we should think of a good tag name :-) I will hold the integration of the current PR for now.

After thinking about this, I think either a new "-Xlog:process", or we could just log it under "-Xlog:os". The latter could maybe benefit from some cleaning up to reduce the noise at info level.

Adding to -Xlog:os seems the right place. I tried -Xlog:os with Eclipse and it wasn't too verbose -- only about 30 lines are printed.

I filed https://bugs.openjdk.java.net/browse/JDK-8270865

@iklam
Copy link
Member Author

iklam commented Jul 17, 2021

Thanks @navyxliu @tstuefe @dholmes-ora @yminqi for the review.
/integrate

@openjdk
Copy link

openjdk bot commented Jul 17, 2021

Going to push as commit f8ec3b6.
Since your change was applied there have been 89 commits pushed to the master branch:

  • a5c9094: Merge
  • 2dddcce: 8270858: Problem List java/awt/Window/MultiWindowApp/MultiWindowAppTest.java on Linux
  • 1350e2b: 8270556: Exclude security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA
  • 58f1ada: 8269636: Change outputStream's print_raw() and print_raw_cr() second parameter to size_t type
  • 67dc1c5: 8270837: fix typos in test TestSigParse.java
  • 1d8d72d: 8270540: G1: Refactor range checking in G1BlockOffsetTablePart::block_start* to asserts
  • 90c219f: 8270547: java.util.Random contains unnecessary @SuppressWarnings("exports")
  • 4927ee4: 8270814: ProblemList the failing serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor* tests
  • 676d425: 8270459: Conflict inlining decisions by C1/C2 with the same CompileCommand
  • eab959c: 8269269: [macos11] SystemIconTest fails with ClassCastException
  • ... and 79 more: https://git.openjdk.java.net/jdk/compare/d6c0f5fa22d2fc07a4d8957d7ad005c03df9f8d2...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 17, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 17, 2021
@openjdk
Copy link

openjdk bot commented Jul 17, 2021

@iklam Pushed as commit f8ec3b6.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

5 participants