equal
deleted
inserted
replaced
57 * @requires vm.hasJFR |
57 * @requires vm.hasJFR |
58 * @requires vm.gc == "G1" | vm.gc == null |
58 * @requires vm.gc == "G1" | vm.gc == null |
59 * @library /test/lib /test/jdk |
59 * @library /test/lib /test/jdk |
60 * @build sun.hotspot.WhiteBox |
60 * @build sun.hotspot.WhiteBox |
61 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
61 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
62 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:MaxTenuringThreshold=1 -Xms20M -Xmx20M |
62 * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+AlwaysTenure |
|
63 * -Xms20M -Xmx20M -Xlog:gc=debug,gc+heap*=debug,gc+ergo*=debug,gc+start=debug |
63 * -XX:G1MixedGCLiveThresholdPercent=100 -XX:G1HeapWastePercent=0 -XX:G1HeapRegionSize=1m |
64 * -XX:G1MixedGCLiveThresholdPercent=100 -XX:G1HeapWastePercent=0 -XX:G1HeapRegionSize=1m |
64 * -XX:+UseG1GC -XX:+UseStringDeduplication |
65 * -XX:+UseG1GC -XX:+UseStringDeduplication |
65 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
66 * -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
66 * jdk.jfr.event.gc.collection.TestG1ParallelPhases |
67 * jdk.jfr.event.gc.collection.TestG1ParallelPhases |
67 */ |
68 */ |
73 Recording recording = new Recording(); |
74 Recording recording = new Recording(); |
74 recording.enable(EventNames.GCPhaseParallel); |
75 recording.enable(EventNames.GCPhaseParallel); |
75 recording.start(); |
76 recording.start(); |
76 |
77 |
77 // create more weak garbage than can fit in this heap (-Xmx20m), will force collection of weak references |
78 // create more weak garbage than can fit in this heap (-Xmx20m), will force collection of weak references |
78 weakRefs = range(1, 100) |
79 weakRefs = range(1, 30) |
79 .mapToObj(n -> new WeakReference<>(new byte[1_000_000])) |
80 .mapToObj(n -> new WeakReference<>(new byte[1_000_000])) |
80 .collect(toList()); // force evaluation of lazy stream (all weak refs must be created) |
81 .collect(toList()); // force evaluation of lazy stream (all weak refs must be created) |
81 |
82 |
82 final var MEG = 1024 * 1024; |
83 final var MEG = 1024 * 1024; |
83 provokeMixedGC(1 * MEG); |
84 provokeMixedGC(1 * MEG); |
148 range(0, g1HeapRegionSize/arraySize).forEach(n -> { |
149 range(0, g1HeapRegionSize/arraySize).forEach(n -> { |
149 liveOldObjects.add(new byte[arraySize]); |
150 liveOldObjects.add(new byte[arraySize]); |
150 toUnreachable.add(new byte[arraySize]); |
151 toUnreachable.add(new byte[arraySize]); |
151 }); |
152 }); |
152 |
153 |
153 // Do two young collections, MaxTenuringThreshold=1 will force promotion. |
154 // Do one young collection, AlwaysTenure will force promotion. |
154 getWhiteBox().youngGC(); |
|
155 getWhiteBox().youngGC(); |
155 getWhiteBox().youngGC(); |
156 |
156 |
157 // Check it is promoted & keep alive |
157 // Check it is promoted & keep alive |
158 Asserts.assertTrue(getWhiteBox().isObjectInOldGen(liveOldObjects), "List of the objects is suppose to be in OldGen"); |
158 Asserts.assertTrue(getWhiteBox().isObjectInOldGen(liveOldObjects), "List of the objects is suppose to be in OldGen"); |
159 Asserts.assertTrue(getWhiteBox().isObjectInOldGen(toUnreachable), "List of the objects is suppose to be in OldGen"); |
159 Asserts.assertTrue(getWhiteBox().isObjectInOldGen(toUnreachable), "List of the objects is suppose to be in OldGen"); |
165 } |
165 } |
166 } |
166 } |
167 |
167 |
168 /** |
168 /** |
169 * The necessary condition for guaranteed mixed GC is running in VM with the following flags: |
169 * The necessary condition for guaranteed mixed GC is running in VM with the following flags: |
170 * -XX:+UnlockExperimentalVMOptions -XX:MaxTenuringThreshold=1 -Xms{HEAP_SIZE}M |
170 * -XX:+UnlockExperimentalVMOptions -XX:+AlwaysTenure -Xms{HEAP_SIZE}M |
171 * -Xmx{HEAP_SIZE}M -XX:G1MixedGCLiveThresholdPercent=100 -XX:G1HeapWastePercent=0 |
171 * -Xmx{HEAP_SIZE}M -XX:G1MixedGCLiveThresholdPercent=100 -XX:G1HeapWastePercent=0 |
172 * -XX:G1HeapRegionSize={REGION_SIZE}m |
172 * -XX:G1HeapRegionSize={REGION_SIZE}m |
173 * |
173 * |
174 * @param provokeSize The size to allocate to provoke the start of a mixed gc (half heap size?) |
|
175 * @param g1HeapRegionSize The size of your regions in bytes |
174 * @param g1HeapRegionSize The size of your regions in bytes |
176 */ |
175 */ |
177 public static void provokeMixedGC(int g1HeapRegionSize) { |
176 public static void provokeMixedGC(int g1HeapRegionSize) { |
178 final var arraySize = 20_000; |
177 final var arraySize = 20_000; |
179 var liveOldObjects = new ArrayList<byte[]>(); |
178 var liveOldObjects = new ArrayList<byte[]>(); |