Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
8214455: Relocate CDS archived regions to the top of the G1 heap
Reviewed-by: tschatzl, ccheung
- Loading branch information
Showing
8 changed files
with
147 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/hotspot/jtreg/runtime/cds/appcds/cacheObject/HeapFragmentationApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2021, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
public class HeapFragmentationApp { | ||
public static void main(String args[]) throws Exception { | ||
int BUF_SIZE = Integer.parseInt(args[0]); | ||
System.out.println("allocating byte[" + BUF_SIZE + "]"); | ||
byte[] array = new byte[BUF_SIZE]; | ||
System.out.println("array = " + array); | ||
System.out.println("array.length = " + array.length); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
test/hotspot/jtreg/runtime/cds/appcds/cacheObject/HeapFragmentationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) 2021, 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 | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @summary Relocate CDS archived regions to the top of the G1 heap | ||
* @bug 8214455 | ||
* @requires vm.cds.archived.java.heap | ||
* @requires (sun.arch.data.model == "64" & os.maxMemory > 4g) | ||
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds | ||
* @build HeapFragmentationApp | ||
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar HeapFragmentationApp.jar HeapFragmentationApp | ||
* @run driver HeapFragmentationTest | ||
*/ | ||
|
||
import jdk.test.lib.process.OutputAnalyzer; | ||
import jdk.test.lib.helpers.ClassFileInstaller; | ||
|
||
public class HeapFragmentationTest { | ||
public static void main(String[] args) throws Exception { | ||
String mainClass = "HeapFragmentationApp"; | ||
String appJar = ClassFileInstaller.getJarPath(mainClass + ".jar"); | ||
String appClasses[] = TestCommon.list(mainClass); | ||
|
||
// We run with a 1400m heap, so we should be able to allocate a 1000m buffer, regardless | ||
// of the heap size chosen at dump time. | ||
String dumpTimeHeapSize = "-Xmx800m"; | ||
String runTimeHeapSize = "-Xmx1400m"; | ||
String BUFF_SIZE = Integer.toString(1000 * 1024 * 1024); | ||
String successOutput = "array.length = " + BUFF_SIZE; | ||
|
||
// On Linux/x64, this would (usually, if not affected by ASLR) force the low end of | ||
// the heap to be at 0x600000000. Thus, the heap ranges would be | ||
// | ||
// dump time: [0x600000000 ... 0x600000000 + 800m] | ||
// [AHR] <- archived heap regions are dumped at here | ||
// | ||
// run time: [0x600000000 ............... 0x600000000 + 1400m] | ||
// [AHR] <- archived heap regions are moved to here | ||
// |<---- max allocatable size ----->| | ||
String heapBase = "-XX:HeapBaseMinAddress=0x600000000"; | ||
|
||
TestCommon.dump(appJar, appClasses, | ||
heapBase, | ||
dumpTimeHeapSize, "-Xlog:cds=debug"); | ||
|
||
String execArgs[] = TestCommon.concat("-cp", appJar, | ||
"-showversion", | ||
heapBase, | ||
"-Xlog:cds=debug", | ||
"-Xlog:gc+heap+exit", | ||
"-Xlog:gc,gc+heap,gc+ergo+heap", | ||
"-XX:+CrashOnOutOfMemoryError", | ||
"-XX:+IgnoreUnrecognizedVMOptions", | ||
"-XX:+G1ExitOnExpansionFailure"); | ||
|
||
// First, make sure the test runs without CDS | ||
TestCommon.runWithoutCDS(TestCommon.concat(execArgs, runTimeHeapSize, mainClass, BUFF_SIZE)) | ||
.assertNormalExit(successOutput); | ||
|
||
// Run with CDS. The archived heap regions should be relocated to avoid fragmentation. | ||
TestCommon.run(TestCommon.concat(execArgs, runTimeHeapSize, mainClass, BUFF_SIZE)) | ||
.assertNormalExit(successOutput); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78d1164
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues