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

8275185: Remove dead code and clean up jvmstat LocalVmManager #5923

Conversation

iklam
Copy link
Member

@iklam iklam commented Oct 13, 2021

LocalVmManager and PerfDataFile have APIs that are supposed to look for VMs owned by a specific user. No one uses these APIs, and they don't work anyway.

The current code is very confusing to look at. Since we're likely to change code in this area for further container support, it's better to clean up the code now.

  • Remove all APIs that take a user name
  • Also removed PerfDataFile.getFile() methods that are unused
  • Cleaned up the code that looks up the hsperfdata_xxx files
    • Fix comments to explain what's happening
    • Avoid using Matcher.reset which is not thread-safe
    • Renamed confusing variables such as userFilter to make the code more readable
    • LocalVmManager.activeVms() probably doesn't need to be synchronized, but I kept it anyway to avoid unnecessary risks.

Testing with Oracle CI: tiers1-4, plus hs-tier5-rt (which tests containers and have extensive use of the management tools).


Progress

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

Issue

  • JDK-8275185: Remove dead code and clean up jvmstat LocalVmManager

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5923

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Oct 13, 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 openjdk bot commented Oct 13, 2021

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

  • serviceability

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 serviceability label Oct 13, 2021
@iklam iklam marked this pull request as ready for review Oct 13, 2021
@openjdk openjdk bot added the rfr label Oct 13, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 13, 2021

Webrevs

/**
* The directory name pattern for the user directories.
*/
public static final String userDirNamePattern = "hsperfdata_\\S*";

/**
* The file name pattern for PerfData shared memory files.
* <p>
* This pattern must be kept in synch with the file name pattern
* used by the 1.4.2 and later HotSpot JVM.
*/
public static final String fileNamePattern = "^[0-9]+$";

/**
* The file name pattern for 1.4.1 PerfData shared memory files.
* <p>
* This pattern must be kept in synch with the file name pattern
* used by the 1.4.1 HotSpot JVM.
*/
public static final String tmpFileNamePattern =
"^hsperfdata_[0-9]+(_[1-2]+)?$";


Copy link
Contributor

@plummercj plummercj Oct 19, 2021

Choose a reason for hiding this comment

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

I don't understand why you thought it best to remove these and instead use hard coded references to these partterns.

Copy link
Member Author

@iklam iklam Oct 19, 2021

Choose a reason for hiding this comment

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

I have two goals

  • these aren't used anywhere else, so it's better to at least move them from this file to LocalVmManager.java, where they are actually used. So you don't need to flip between two files.
  • the behavior is easier to understand if the string literals, comments, and the code that uses them are together.

Note that the original code has plenty of comment that are rather useless if you want to know how the files are searched.

Copy link
Contributor

@plummercj plummercj Oct 19, 2021

Choose a reason for hiding this comment

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

ok

/**
* The directory name pattern for the user directories.
*/
public static final String userDirNamePattern = "hsperfdata_\\S*";

/**
* The file name pattern for PerfData shared memory files.
* <p>
* This pattern must be kept in synch with the file name pattern
* used by the 1.4.2 and later HotSpot JVM.
*/
public static final String fileNamePattern = "^[0-9]+$";

/**
* The file name pattern for 1.4.1 PerfData shared memory files.
* <p>
* This pattern must be kept in synch with the file name pattern
* used by the 1.4.1 HotSpot JVM.
*/
public static final String tmpFileNamePattern =
"^hsperfdata_[0-9]+(_[1-2]+)?$";


Copy link
Contributor

@plummercj plummercj Oct 19, 2021

Choose a reason for hiding this comment

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

ok

}
}
}
// 1.4.2 and later: Look for the files {tmpdir}/hsperfdata_{any_user_name}/[0-0]+
Copy link
Contributor

@plummercj plummercj Oct 19, 2021

Choose a reason for hiding this comment

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

should be [0-9]+

Copy link
Member Author

@iklam iklam Nov 4, 2021

Choose a reason for hiding this comment

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

Fixed.

tmpFileFilter = new FilenameFilter() {
// 1.4.1 (or earlier?): the files are stored directly under {tmpdir}/ with
// the following pattern.
Pattern oldtmpFilePattern = Pattern.compile("^hsperfdata_[0-9]+(_[1-2]+)?$");
Copy link
Contributor

@plummercj plummercj Oct 19, 2021

Choose a reason for hiding this comment

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

So this pattern optionally has _ followed by a sequence of 1's and 2's at the end? Seems odd.

Copy link
Member Author

@iklam iklam Nov 4, 2021

Choose a reason for hiding this comment

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

I restored this line to use PerfDataFile.tmpFileNamePattern, as before my changes. Yes, that's an odd way of naming a file.

@sspitsyn
Copy link
Contributor

@sspitsyn sspitsyn commented Oct 20, 2021

Hi Ioi,
It looks good to me except the line 105 commented by Chris.
I wonder how should this be tested to make sure there are no regressions.
Do we really care about pre 1.4.2 formats? If so, what is the way to test it?
We have a little lack of knowledge in this area.
I guess, we need the performance team to get involved into this review.
Thanks,
Serguei

@kevinjwalls
Copy link

@kevinjwalls kevinjwalls commented Oct 26, 2021

Nice cleanup - although was it not better for PerfDataFile.java to "own" the definitions of what a perfdata filename looks like?
That might be what Chris was hinting at. There isn't really that much flipping between two files. 8-)

@iklam
Copy link
Member Author

@iklam iklam commented Nov 4, 2021

Hi Ioi, It looks good to me except the line 105 commented by Chris. I wonder how should this be tested to make sure there are no regressions. Do we really care about pre 1.4.2 formats? If so, what is the way to test it? We have a little lack of knowledge in this area. I guess, we need the performance team to get involved into this review. Thanks, Serguei

I am not sure about 1.4.2 formats. I guess we don't really care, but we should probably remove it in a separate RFE. I am trying to keep this PR from having any functional changes, and will just remove dead code.

For testing, I am running tiers 1-4. Will that be enough?

I'll ping the performance team.

Thanks

  • Ioi

@iklam
Copy link
Member Author

@iklam iklam commented Nov 4, 2021

Nice cleanup - although was it not better for PerfDataFile.java to "own" the definitions of what a perfdata filename looks like? That might be what Chris was hinting at. There isn't really that much flipping between two files. 8-)

Hi Kevin, thanks for the review. I've moved the filename patterns back to PerfDataFile.java as you suggested.

@openjdk
Copy link

@openjdk openjdk bot commented Nov 4, 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:

8275185: Remove dead code and clean up jvmstat LocalVmManager

Reviewed-by: cjplummer, redestad, kevinw

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

  • 3613ce7: 8275586: Zero: Simplify interpreter initialization
  • c62b347: 8276623: JDK-8275650 accidentally pushed "out" file
  • a1f4c42: 8276227: ciReplay: SIGSEGV if classfile for replay compilation is not present after JDK-8275868
  • 9eadcbb: 8276217: Harmonize StrictMath intrinsics handling
  • fb0be81: 8276096: Simplify Unsafe.{load|store}Fence fallbacks by delegating to fullFence
  • 558ee40: 8276615: Update CR number of some tests in ProblemList-zgc.txt
  • 603bba2: 8271420: Extend CDS custom loader support to Windows platform
  • ce8c767: 8276220: Reduce excessive allocations in DateTimeFormatter
  • 0ab910d: 8276066: Reset LoopPercentProfileLimit for x86 due to suboptimal performance
  • f3320d2: 8276588: Change "ccc" to "CSR" in HotSpot sources
  • ... and 20 more: https://git.openjdk.java.net/jdk/compare/495c828ae95205885b091dde795b517ba332a2b1...master

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 label Nov 4, 2021
cl4es
cl4es approved these changes Nov 4, 2021
Copy link
Member

@cl4es cl4es left a comment

Supporting 1.4.1 hsperfdata seems pointless at this point, so I support a removal of that code. It also seems reasonable to do as a follow-up, as @iklam suggests, rather than shifting the scope this PR.

@kevinjwalls
Copy link

@kevinjwalls kevinjwalls commented Nov 4, 2021

...moved the filename patterns back to PerfDataFile.java...

Thanks, looks good!

@iklam
Copy link
Member Author

@iklam iklam commented Nov 5, 2021

Thanks @plummercj @kevinjwalls @cl4es for the review. I filed https://bugs.openjdk.java.net/browse/JDK-8276687 to remove the JDK 1.4.1 support.
Passed Oracle CI tiers1-4
/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Nov 5, 2021

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

  • 396132f: 8275509: ModuleDescriptor.hashCode isn't reproducible across builds
  • 9ad4d3d: 8276025: Hotspot's libsvml.so may conflict with user dependency
  • e21b5c7: 8276650: GenGraphs does not produce deterministic output
  • 7b1916e: 8233557: [TESTBUG] DoubleClickTitleBarTest.java fails on macOs
  • 8ec80c4: 8276653: Missing row headers in j.l.Character docs
  • 7e87f94: 8276652: Missing row headers in MethodHandles.Lookup docs
  • dcf36f8: 8275670: ciReplay: java.lang.NoClassDefFoundError when trying to load java/lang/invoke/LambdaForm$MH
  • 81203ef: 8276655: Use blessed modifier order in SCTP
  • 2b5a32c: 8275718: Relax memory constraint on exception counter updates
  • 99d4b07: 8276649: MethodHandles.Lookup docs: replace the table in the cross-module access check section with list
  • ... and 41 more: https://git.openjdk.java.net/jdk/compare/495c828ae95205885b091dde795b517ba332a2b1...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Nov 5, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Nov 5, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Nov 5, 2021

@iklam Pushed as commit 8e17ce0.

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

@sspitsyn
Copy link
Contributor

@sspitsyn sspitsyn commented Nov 6, 2021

Hi Ioi,
Sorry for being late here.
Just to complete this...
Thank you for your answers! I'm okay with them.

@iklam
Copy link
Member Author

@iklam iklam commented Nov 6, 2021

Hi Ioi,
Sorry for being late here.
Just to complete this...
Thank you for your answers! I'm okay with them.

Thanks Serguei!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated serviceability
6 participants