Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8311514: Incorrect regex in TestMetaSpaceLog.java #14782

Closed
wants to merge 3 commits into from

Conversation

quadhier
Copy link
Contributor

@quadhier quadhier commented Jul 6, 2023

The regex in jtreg test TestMetaSpaceLog.java is intended to capture the metaspace size before and after the reclamation. But it captures the wrong value. which might cause this test to always pass. The results of the capture can be displayed using a visualization tool.

Before this patch:
屏幕快照 2023-07-06 17 18 15

After this patch:
屏幕快照 2023-07-06 17 18 25


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8311514: Incorrect regex in TestMetaSpaceLog.java (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14782/head:pull/14782
$ git checkout pull/14782

Update a local copy of the PR:
$ git checkout pull/14782
$ git pull https://git.openjdk.org/jdk.git pull/14782/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14782

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14782.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 6, 2023

👋 Welcome back dqu! 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 openjdk bot added the rfr Pull request is ready for review label Jul 6, 2023
@openjdk
Copy link

openjdk bot commented Jul 6, 2023

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

  • hotspot-gc

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-gc hotspot-gc-dev@openjdk.org label Jul 6, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 6, 2023

Webrevs

@tstuefe
Copy link
Member

tstuefe commented Jul 6, 2023

Good catch. But is this guaranteed to always be in K?

@quadhier
Copy link
Contributor Author

quadhier commented Jul 6, 2023

Good catch. But is this guaranteed to always be in K?

Hi Thomas! That's a good question and I believe the answer is yes.

This message is printed here in the function MetaspaceUtils::print_metaspace_change():

if (Metaspace::using_class_space()) {
log_info(gc, metaspace)(HEAP_CHANGE_FORMAT" "
HEAP_CHANGE_FORMAT" "
HEAP_CHANGE_FORMAT,
HEAP_CHANGE_FORMAT_ARGS("Metaspace",
pre_meta_values.used(),
pre_meta_values.committed(),
meta_values.used(),
meta_values.committed()),
HEAP_CHANGE_FORMAT_ARGS("NonClass",
pre_meta_values.non_class_used(),
pre_meta_values.non_class_committed(),
meta_values.non_class_used(),
meta_values.non_class_committed()),
HEAP_CHANGE_FORMAT_ARGS("Class",
pre_meta_values.class_used(),
pre_meta_values.class_committed(),
meta_values.class_used(),
meta_values.class_committed()));
} else {
log_info(gc, metaspace)(HEAP_CHANGE_FORMAT,
HEAP_CHANGE_FORMAT_ARGS("Metaspace",
pre_meta_values.used(),
pre_meta_values.committed(),
meta_values.used(),
meta_values.committed()));
}

And the definition of macros HEAP_CHANGE_FORMAT and HEAP_CHANGE_FORMAT_ARGS is:

// Memory size transition formatting.
#define HEAP_CHANGE_FORMAT "%s: " SIZE_FORMAT "K(" SIZE_FORMAT "K)->" SIZE_FORMAT "K(" SIZE_FORMAT "K)"
#define HEAP_CHANGE_FORMAT_ARGS(_name_, _prev_used_, _prev_capacity_, _used_, _capacity_) \
(_name_), (_prev_used_) / K, (_prev_capacity_) / K, (_used_) / K, (_capacity_) / K

@tstuefe
Copy link
Member

tstuefe commented Jul 6, 2023

Good catch. But is this guaranteed to always be in K?

Hi Thomas! That's a good question and I believe the answer is yes.

Okay, thanks for checking. The test will fail should the JVM ever change that format, right?

@quadhier
Copy link
Contributor Author

quadhier commented Jul 6, 2023

The test will fail should the JVM ever change that format, right?

I believe it will, except for some coincidence with a very very low possibility (eg, it matches a text that is embedded in some other log with a totally different meaning).

This reminds me of changing this regex to match more parts of this log, which will make it more likely to fail if this log changes.

@quadhier
Copy link
Contributor Author

quadhier commented Jul 6, 2023

I have pushed a new commit to match more parts of the metaspace change log and added a comment in this test.

This is the current match result, and the test still passes (I have also checked that the test will fail if a regex captures nothing).
屏幕快照 2023-07-06 19 34 50

@quadhier
Copy link
Contributor Author

quadhier commented Jul 6, 2023

My fault. I see a test failure because that the "NonClass ... Class ..." part might not appear in the log, as suggested by the else branch in MetaspaceUtils::print_metaspace_change(). I'll fix that.

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.

Can you please use \d+ for numbers?
Also, maybe define ([0-9]+)K as substring once and assemble the regex from that?

@quadhier
Copy link
Contributor Author

quadhier commented Jul 6, 2023

Can you please use \d+ for numbers?
Also, maybe define ([0-9]+)K as substring once and assemble the regex from that?

Good idea as I find my regex sort of explodes. :P

@quadhier
Copy link
Contributor Author

quadhier commented Jul 6, 2023

It looks cleaner now. Let's wait for the CI again.

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.

Good. Test errors on x86 unrelated.

@openjdk
Copy link

openjdk bot commented Jul 6, 2023

@quadhier 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:

8311514: Incorrect regex in TestMetaSpaceLog.java

Reviewed-by: stuefe

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 10 new commits pushed to the master branch:

  • 25cbe85: 8310550: Adjust references to rt.jar
  • 848abd2: 8311511: Improve description of NativeLibrary JFR event
  • 6485b7d: 6875229: Wrong placement of icons in JTabbedPane in Nimbus
  • 27de536: 8311581: Remove obsolete code and comments in TestLVT.java
  • e848d94: 8310923: Refactor Currency tests to use JUnit
  • 0c86c31: 8302351: "assert(!JavaThread::current()->is_interp_only_mode() || !nm->method()->is_continuation_enter_intrinsic() || ContinuationEntry::is_interpreted_call(return_pc)) failed: interp_only_mode but not in enterSpecial interpreted entry" in fixup_callers_callsite
  • ec7da91: 8240567: MethodTooLargeException thrown while creating a jlink image
  • 97e99f0: 8311087: PhiNode::wait_for_region_igvn should break early
  • 7173c30: 8307766: Linux: Provide the option to override the timer slack
  • 356067d: 8311489: Remove unused dirent_md files

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@tstuefe) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 6, 2023
@quadhier
Copy link
Contributor Author

quadhier commented Jul 7, 2023

Test errors on x86 unrelated.

Yep. Thanks for your review and nice suggestions, Thomas!

@quadhier
Copy link
Contributor Author

quadhier commented Jul 7, 2023

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 7, 2023
@openjdk
Copy link

openjdk bot commented Jul 7, 2023

@quadhier
Your change (at version 68c1a65) is now ready to be sponsored by a Committer.

@quadhier
Copy link
Contributor Author

quadhier commented Jul 7, 2023

Hi @tstuefe, could you please sponsor this change? Thanks in advance!

@tstuefe
Copy link
Member

tstuefe commented Jul 7, 2023

@quadhier Technically this would need two reviewers, since its a hotspot-related test. But this is trivial enough to make this a Trivial change, which just needs one reviewer.

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 7, 2023

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

  • 0ef03f1: 8311285: report some fontconfig related environment variables in hs_err file
  • 92ca670: 8310170: Use sp's argument to improve performance of outputStream::indent and remove SP_USE_TABS
  • 25cbe85: 8310550: Adjust references to rt.jar
  • 848abd2: 8311511: Improve description of NativeLibrary JFR event
  • 6485b7d: 6875229: Wrong placement of icons in JTabbedPane in Nimbus
  • 27de536: 8311581: Remove obsolete code and comments in TestLVT.java
  • e848d94: 8310923: Refactor Currency tests to use JUnit
  • 0c86c31: 8302351: "assert(!JavaThread::current()->is_interp_only_mode() || !nm->method()->is_continuation_enter_intrinsic() || ContinuationEntry::is_interpreted_call(return_pc)) failed: interp_only_mode but not in enterSpecial interpreted entry" in fixup_callers_callsite
  • ec7da91: 8240567: MethodTooLargeException thrown while creating a jlink image
  • 97e99f0: 8311087: PhiNode::wait_for_region_igvn should break early
  • ... and 2 more: https://git.openjdk.org/jdk/compare/3d813ae39f4422dd47473608eb8911e2483c6c32...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 7, 2023
@openjdk openjdk bot closed this Jul 7, 2023
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 7, 2023
@openjdk openjdk bot removed rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Jul 7, 2023
@openjdk
Copy link

openjdk bot commented Jul 7, 2023

@tstuefe @quadhier Pushed as commit 9084b6c.

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

@quadhier
Copy link
Contributor Author

quadhier commented Jul 7, 2023

Okay! Thanks for your explanations, Thomas. I'll pay attention to that.

@tstuefe
Copy link
Member

tstuefe commented Jul 7, 2023

Okay! Thanks for your explanations, Thomas. I'll pay attention to that.

No problem, and thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated
2 participants