< prev index next >

test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java

Print this page

 57 /*
 58  * @test id=valid_large_cds
 59  * @bug 8022865
 60  * @summary Tests for the -XX:CompressedClassSpaceSize command line option
 61  * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true & vm.cds
 62  * @requires vm.flagless
 63  * @library /test/lib
 64  * @modules java.base/jdk.internal.misc java.management
 65  * @run driver CompressedClassSpaceSize valid_large_cds
 66  */
 67 
 68 import jdk.test.lib.process.ProcessTools;
 69 import jdk.test.lib.process.OutputAnalyzer;
 70 
 71 public class CompressedClassSpaceSize {
 72 
 73     final static long MB = 1024 * 1024;
 74 
 75     final static long minAllowedClassSpaceSize = MB;
 76     final static long minRealClassSpaceSize = 16 * MB;
 77     final static long maxClassSpaceSize = 4096 * MB;
 78 
 79     // For the valid_large_cds sub test: we need to have a notion of what archive size to
 80     // maximally expect, with a generous fudge factor to avoid having to tweak this test
 81     // ofent. Note: today's default archives are around 16-20 MB.
 82     final static long maxExpectedArchiveSize = 512 * MB;
 83 
 84     public static void main(String[] args) throws Exception {
 85         ProcessBuilder pb;
 86         OutputAnalyzer output;
 87 
 88         switch (args[0]) {
 89             case "invalid": {
 90                 // < Minimum size
 91                 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
 92                         "-version");
 93                 output = new OutputAnalyzer(pb.start());
 94                 output.shouldContain("outside the allowed range")
 95                         .shouldHaveExitValue(1);
 96 
 97                 // Invalid size of -1 should be handled correctly

115                 // Note that this is **reserved** size and does not affect rss.
116                 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
117                         "-XX:CompressedClassSpaceSize=" + minAllowedClassSpaceSize,
118                         "-Xlog:gc+metaspace",
119                         "-version");
120                 output = new OutputAnalyzer(pb.start());
121                 output.shouldMatch("Compressed class space.*" + minRealClassSpaceSize)
122                         .shouldHaveExitValue(0);
123             }
124             break;
125             case "valid_large_nocds": {
126                 // Without CDS, we should get 4G
127                 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
128                         "-Xshare:off", "-Xlog:metaspace*", "-version");
129                 output = new OutputAnalyzer(pb.start());
130                 output.shouldMatch("Compressed class space.*" + maxClassSpaceSize)
131                         .shouldHaveExitValue(0);
132             }
133             break;
134             case "valid_large_cds": {
135                 // Create archive
136                 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
137                         "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:dump", "-version");
138                 output = new OutputAnalyzer(pb.start());
139                 output.shouldHaveExitValue(0);

140 
141                 // With CDS, class space should fill whatever the CDS archive leaves us (modulo alignment)
142                 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
143                         "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:on", "-Xlog:metaspace*", "-version");
144                 output = new OutputAnalyzer(pb.start());
145                 output.shouldHaveExitValue(0);
146                 long reducedSize = Long.parseLong(
147                         output.firstMatch("reducing class space size from " + maxClassSpaceSize + " to (\\d+)", 1));
148                 if (reducedSize < (maxClassSpaceSize - maxExpectedArchiveSize)) {
149                     output.reportDiagnosticSummary();
150                     throw new RuntimeException("Class space size too small?");
151                 }
152                 output.shouldMatch("Compressed class space.*" + reducedSize);
153             }
154             break;
155             default:
156                 throw new RuntimeException("invalid sub test " + args[0]);
157         }
158     }
159 }

 57 /*
 58  * @test id=valid_large_cds
 59  * @bug 8022865
 60  * @summary Tests for the -XX:CompressedClassSpaceSize command line option
 61  * @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true & vm.cds
 62  * @requires vm.flagless
 63  * @library /test/lib
 64  * @modules java.base/jdk.internal.misc java.management
 65  * @run driver CompressedClassSpaceSize valid_large_cds
 66  */
 67 
 68 import jdk.test.lib.process.ProcessTools;
 69 import jdk.test.lib.process.OutputAnalyzer;
 70 
 71 public class CompressedClassSpaceSize {
 72 
 73     final static long MB = 1024 * 1024;
 74 
 75     final static long minAllowedClassSpaceSize = MB;
 76     final static long minRealClassSpaceSize = 16 * MB;
 77     final static long maxClassSpaceSize = 512 * MB;
 78 
 79     // For the valid_large_cds sub test: we need to have a notion of what archive size to
 80     // maximally expect, with a generous fudge factor to avoid having to tweak this test
 81     // ofent. Note: today's default archives are around 16-20 MB.
 82     final static long maxExpectedArchiveSize = 512 * MB;
 83 
 84     public static void main(String[] args) throws Exception {
 85         ProcessBuilder pb;
 86         OutputAnalyzer output;
 87 
 88         switch (args[0]) {
 89             case "invalid": {
 90                 // < Minimum size
 91                 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=0",
 92                         "-version");
 93                 output = new OutputAnalyzer(pb.start());
 94                 output.shouldContain("outside the allowed range")
 95                         .shouldHaveExitValue(1);
 96 
 97                 // Invalid size of -1 should be handled correctly

115                 // Note that this is **reserved** size and does not affect rss.
116                 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions",
117                         "-XX:CompressedClassSpaceSize=" + minAllowedClassSpaceSize,
118                         "-Xlog:gc+metaspace",
119                         "-version");
120                 output = new OutputAnalyzer(pb.start());
121                 output.shouldMatch("Compressed class space.*" + minRealClassSpaceSize)
122                         .shouldHaveExitValue(0);
123             }
124             break;
125             case "valid_large_nocds": {
126                 // Without CDS, we should get 4G
127                 pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
128                         "-Xshare:off", "-Xlog:metaspace*", "-version");
129                 output = new OutputAnalyzer(pb.start());
130                 output.shouldMatch("Compressed class space.*" + maxClassSpaceSize)
131                         .shouldHaveExitValue(0);
132             }
133             break;
134             case "valid_large_cds": {
135                 // TODO: Does not currently work with +UseCompactObjectHeaders.
136                 // // Create archive
137                 // pb = ProcessTools.createLimitedTestJavaProcessBuilder(
138                 //         "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:dump", "-version");
139                 // output = new OutputAnalyzer(pb.start());
140                 // output.shouldHaveExitValue(0);
141 
142                 // // With CDS, class space should fill whatever the CDS archive leaves us (modulo alignment)
143                 // pb = ProcessTools.createLimitedTestJavaProcessBuilder("-XX:CompressedClassSpaceSize=" + maxClassSpaceSize,
144                 //         "-XX:SharedArchiveFile=./abc.jsa", "-Xshare:on", "-Xlog:metaspace*", "-version");
145                 // output = new OutputAnalyzer(pb.start());
146                 // output.shouldHaveExitValue(0);
147                 // long reducedSize = Long.parseLong(
148                 //         output.firstMatch("reducing class space size from " + maxClassSpaceSize + " to (\\d+)", 1));
149                 // if (reducedSize < (maxClassSpaceSize - maxExpectedArchiveSize)) {
150                 //     output.reportDiagnosticSummary();
151                 //     throw new RuntimeException("Class space size too small?");
152                 // }
153                 // output.shouldMatch("Compressed class space.*" + reducedSize);
154             }
155             break;
156             default:
157                 throw new RuntimeException("invalid sub test " + args[0]);
158         }
159     }
160 }
< prev index next >