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

JDK-8296796: Provide clean, platform-agnostic interface to C-heap trimming #11089

Conversation

tstuefe
Copy link
Member

@tstuefe tstuefe commented Nov 10, 2022

This is a breakout from JDK-8293114, which is starved for reviews. So I attempt to break up that fix into smaller units which are hopefully easier to review separately.

We can trim the C-heap manually using jcmd since JDK-8268893. This patch reshapes this code, cleaning it up in an OS-agnostic way. That will allow us to add implementions for other platforms (I have this on my list for AIX at least) and make review of 8293114 easier.


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-8296796: Provide clean, platform-agnostic interface to C-heap trimming

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11089

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 10, 2022

👋 Welcome back stuefe! 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.

@tstuefe tstuefe force-pushed the JDK-8296796-factor-out-os-trim-native-heap branch from e0d3481 to 2b4c0ea Compare November 10, 2022 13:25
@openjdk openjdk bot changed the title JDK-8296796: Provide clean, platform-agnostic interface to C-heap trimming 8296796: Provide clean, platform-agnostic interface to C-heap trimming Nov 10, 2022
@openjdk
Copy link

openjdk bot commented Nov 10, 2022

@tstuefe The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

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

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Nov 10, 2022
@tstuefe tstuefe force-pushed the JDK-8296796-factor-out-os-trim-native-heap branch from 2b4c0ea to 3b93fb8 Compare November 10, 2022 13:38
@tstuefe
Copy link
Member Author

tstuefe commented Nov 10, 2022

riscv build error unrelated

@tstuefe tstuefe marked this pull request as ready for review November 10, 2022 15:55
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 10, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 10, 2022

Webrevs

@tstuefe
Copy link
Member Author

tstuefe commented Nov 13, 2022

x86 test error unrelated

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.

This looks good for doing what it says, but I have to wonder whether it is actually worthwhile doing this unless most OS/lib will support it? What will the implementation be in AIX?

Thanks

@@ -372,6 +372,9 @@ inline T byte_size_in_proper_unit(T s) {
}
}

#define PROPERFMT SIZE_FORMAT "%s"
#define PROPERFMTARGS(S) byte_size_in_proper_unit(S), proper_unit_for_byte_size(S)
Copy link
Member

Choose a reason for hiding this comment

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

style nit? lower-case 's'

@tstuefe
Copy link
Member Author

tstuefe commented Nov 14, 2022

This looks good for doing what it says, but I have to wonder whether it is actually worthwhile doing this unless most OS/lib will support it? What will the implementation be in AIX?

I think C-Heap trimming is useful even if only Linux does it. Linux is arguably the most important platform. And #10085 would bring demonstratable benefits but did not garner a lot of interest. So I hope to speed it up by splitting parts that are hopefully non-contentious into separate RFEs.

I know that AIX has an API to disclaim memory, but have not yet looked deeply into the integration. I also cannot rule out that other platforms may give us similar APIs in the future.

@openjdk-notifier
Copy link

@tstuefe Please do not rebase or force-push to an active PR as it invalidates existing review comments. All changes will be squashed into a single commit automatically when integrating. See OpenJDK Developers’ Guide for more information.

@tstuefe tstuefe changed the title 8296796: Provide clean, platform-agnostic interface to C-heap trimming JDK-8296796: Provide clean, platform-agnostic interface to C-heap trimming Nov 14, 2022
@dholmes-ora
Copy link
Member

I don't disagree that C-heap trimming is useful even if only Linux does it. My objection is to defining a platform-agnostic API when only Linux does it.

@tstuefe
Copy link
Member Author

tstuefe commented Nov 17, 2022

I don't disagree that C-heap trimming is useful even if only Linux does it. My objection is to defining a platform-agnostic API when only Linux does it.

I see. It will allow us to use these APIs in shared code though, without having to use platform ifdefs. We do similar things for other platforms (e.g. see os::map_stack_shadow_pages).

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.

Okay. I have some reservations about this style of approach but the precedents are there. I'd argue that for single-use situations like this and os::map_stack_shadow_pages that a XXX_ONLY(foo();) in the shared code would be acceptable. Others may disagree.

Thanks.

@openjdk
Copy link

openjdk bot commented Nov 18, 2022

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

8296796: Provide clean, platform-agnostic interface to C-heap trimming

Reviewed-by: dholmes, rkennke

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Nov 18, 2022
@tstuefe
Copy link
Member Author

tstuefe commented Nov 18, 2022

Okay. I have some reservations about this style of approach but the precedents are there. I'd argue that for single-use situations like this and os::map_stack_shadow_pages that a XXX_ONLY(foo();) in the shared code would be acceptable. Others may disagree.

Thanks David. I myself lean towards ifdefs too than having to search for the one platform implementation that actually does something. But I caught flak in the past for too many ifdefs. If it annoys us after JDK-8293114 and no second platform implementation is forthcoming, I'll remove the APIs from shared os.

Copy link
Contributor

@rkennke rkennke left a comment

Choose a reason for hiding this comment

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

Looks good to me. I kinda like the OS interface. If the proliferation of lots of unimplemented methods in os/* is a concern, we could provide default impls in shared if !GLIBC as a middle-ground. WDYT?

@tstuefe
Copy link
Member Author

tstuefe commented Nov 18, 2022

Looks good to me.

Thank you!

I kinda like the OS interface. If the proliferation of lots of unimplemented methods in os/* is a concern, we could provide default impls in shared if !GLIBC as a middle-ground. WDYT?

I fear this would annoy people even more than platform defines. Ioi did use something with "HAVE_xxxx_xxxx" macros to provide default implementations for similar things, but I think in this case we are talking about so little code, its not worth the trouble.

@tstuefe
Copy link
Member Author

tstuefe commented Nov 19, 2022

Okay, I manually tested fastdebug on Alpine and on 32-bit. Also re-merged. If all tests run through with no attributable errors, I'll push.

Thanks @dholmes-ora @rkennke for reviewing!

@tstuefe
Copy link
Member Author

tstuefe commented Nov 19, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Nov 19, 2022

Going to push as commit 0845b39.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 19, 2022
@openjdk openjdk bot closed this Nov 19, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 19, 2022
@openjdk
Copy link

openjdk bot commented Nov 19, 2022

@tstuefe Pushed as commit 0845b39.

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

@dholmes-ora
Copy link
Member

We had a strange quirk in our CI testing after this was pushed and it made me think a little differently about the change. If rss_change is only needed for the test then we should perhaps make it (and the test) debug only? Also the rss_change logic seems not to be thread-safe, so only useful for that single-threaded test.

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

Successfully merging this pull request may close these issues.

3 participants