Skip to content

Commit

Permalink
8325496: Make TrimNativeHeapInterval a product switch
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, mbaesken
  • Loading branch information
tstuefe committed Feb 21, 2024
1 parent 27003b5 commit d31fd78
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1987,7 +1987,7 @@ const int ObjectAlignmentInBytes = 8;
"2: monitors & new lightweight locking (LM_LIGHTWEIGHT)") \
range(0, 2) \
\
product(uint, TrimNativeHeapInterval, 0, EXPERIMENTAL, \
product(uint, TrimNativeHeapInterval, 0, \
"Interval, in ms, at which the JVM will trim the native heap if " \
"the platform supports that. Lower values will reclaim memory " \
"more eagerly at the cost of higher overhead. A value of 0 " \
Expand Down
13 changes: 12 additions & 1 deletion src/java.base/share/man/java.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
.\" Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1482,6 +1482,17 @@ usage by individual \f[V]CallSite\f[R], individual virtual memory region
and its committed regions.
.RE
.TP
\f[V]-XX:TrimNativeHeapInterval=\f[R]\f[I]millis\f[R]
Interval, in ms, at which the JVM will trim the native heap.
Lower values will reclaim memory more eagerly at the cost of higher
overhead.
A value of 0 (default) disables native heap trimming.
Native heap trimming is performed in a dedicated thread.
.RS
.PP
This option is only supported on Linux with GNU C Library (glibc).
.RE
.TP
\f[V]-XX:+NeverActAsServerClassMachine\f[R]
Enable the \[dq]Client VM emulation\[dq] mode which only uses the C1 JIT
compiler, a 32Mb CodeCache and the Serial GC.
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/gtest/NativeHeapTrimmerGtest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023 Red Hat, Inc. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,5 +29,5 @@
* @modules java.base/jdk.internal.misc
* java.xml
* @requires vm.flagless
* @run main/native GTestWrapper --gtest_filter=os.trim* -Xlog:trimnative -XX:+UnlockExperimentalVMOptions -XX:TrimNativeHeapInterval=100
* @run main/native GTestWrapper --gtest_filter=os.trim* -Xlog:trimnative -XX:TrimNativeHeapInterval=100
*/
14 changes: 7 additions & 7 deletions test/hotspot/jtreg/runtime/os/TestTrimNative.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2023 SAP SE. All rights reserved.
* Copyright (c) 2023 Red Hat, Inc. All rights reserved.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -278,7 +278,7 @@ public static void main(String[] args) throws Exception {
long trimInterval = 500; // twice per second
long ms1 = System.currentTimeMillis();
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=" + trimInterval },
new String[] { "-XX:TrimNativeHeapInterval=" + trimInterval },
new String[] { TestTrimNative.Tester.class.getName(), "5000" }
);
long ms2 = System.currentTimeMillis();
Expand All @@ -293,7 +293,7 @@ public static void main(String[] args) throws Exception {

case "trimNativeHighInterval": {
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=" + Integer.MAX_VALUE },
new String[] { "-XX:TrimNativeHeapInterval=" + Integer.MAX_VALUE },
new String[] { TestTrimNative.Tester.class.getName(), "5000" }
);
checkExpectedLogMessages(output, true, Integer.MAX_VALUE);
Expand All @@ -305,7 +305,7 @@ public static void main(String[] args) throws Exception {
case "trimNativeLowIntervalStrict": {
long ms1 = System.currentTimeMillis();
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" },
new String[] { "-XX:TrimNativeHeapInterval=1" },
new String[] { TestTrimNative.Tester.class.getName(), "0" }
);
long ms2 = System.currentTimeMillis();
Expand All @@ -316,7 +316,7 @@ public static void main(String[] args) throws Exception {

case "testOffOnNonCompliantPlatforms": {
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" },
new String[] { "-XX:TrimNativeHeapInterval=1" },
new String[] { "-version" }
);
checkExpectedLogMessages(output, false, 0);
Expand All @@ -327,7 +327,7 @@ public static void main(String[] args) throws Exception {

case "testOffExplicit": {
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=0" },
new String[] { "-XX:TrimNativeHeapInterval=0" },
new String[] { "-version" }
);
checkExpectedLogMessages(output, false, 0);
Expand Down

7 comments on commit d31fd78

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d31fd78 Feb 22, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport d31fd78d to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/java.base/share/man/java.1
  • test/hotspot/jtreg/gtest/NativeHeapTrimmerGtest.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-d31fd78d

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790

# Backport the commit
$ git cherry-pick --no-commit d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d31fd78d from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 21 Feb 2024 and was reviewed by David Holmes and Matthias Baesken.

Thanks!

@MBaesken
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk22u

@openjdk
Copy link

@openjdk openjdk bot commented on d31fd78 Feb 22, 2024

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch backport-MBaesken-d31fd78d in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d31fd78d from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 21 Feb 2024 and was reviewed by David Holmes and Matthias Baesken.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-MBaesken-d31fd78d:backport-MBaesken-d31fd78d
$ git checkout backport-MBaesken-d31fd78d
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-MBaesken-d31fd78d

@MBaesken
Copy link
Member

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on d31fd78 Feb 23, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport d31fd78d to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/java.base/share/man/java.1

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-d31fd78d

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790

# Backport the commit
$ git cherry-pick --no-commit d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport d31fd78d963d5d103b1b1bf66ae0bdbe4be2b790.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit d31fd78d from the openjdk/jdk repository.

The commit being backported was authored by Thomas Stuefe on 21 Feb 2024 and was reviewed by David Holmes and Matthias Baesken.

Thanks!

Please sign in to comment.