diff --git a/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java b/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java index 7af81fabe13..2af784fd034 100644 --- a/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java +++ b/test/hotspot/jtreg/gc/shenandoah/generational/TestOldGrowthTriggers.java @@ -1,5 +1,6 @@ /* * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. + * Copyright (c) 2026, 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 @@ -25,15 +26,14 @@ /* * @test id=generational * @summary Test that growth of old-gen triggers old-gen marking - * @key intermittent * @requires vm.gc.Shenandoah * @requires vm.flagless * @library /test/lib * @run driver TestOldGrowthTriggers */ -import java.util.*; -import java.math.BigInteger; +import java.util.Arrays; +import java.util.BitSet; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; @@ -41,36 +41,40 @@ import jdk.test.lib.process.OutputAnalyzer; public class TestOldGrowthTriggers { public static void makeOldAllocations() { - // Expect most of the BigInteger entries placed into array to be promoted, and most will eventually become garbage within old + // Expect most of the BitSet entries placed into array to be promoted, and most will eventually become garbage within old - final int ArraySize = 512 * 1024; // 512K entries - final int BitsInBigInteger = 128; - final int RefillIterations = 64; - BigInteger array[] = new BigInteger[ArraySize]; - Random r = new Random(46); + final int ArraySize = 1024; // 1K entries + final int RefillIterations = 128; + BitSet[] array = new BitSet[ArraySize]; for (int i = 0; i < ArraySize; i++) { - array[i] = new BigInteger(BitsInBigInteger, r); + array[i] = new BitSet(256 * 1024); } for (int refillCount = 0; refillCount < RefillIterations; refillCount++) { - // Each refill repopulates ArraySize randomly selected elements within array - for (int i = 0; i < ArraySize; i++) { - int replaceIndex = r.nextInt(ArraySize); - int deriveIndex = r.nextInt(ArraySize); + // Each refill repopulates ArraySize + for (int i = 1; i < ArraySize; i++) { + int replaceIndex = i; + int deriveIndex = i-1; + switch (i & 0x7) { - case 0,1,2: - // creates new old BigInteger, releases old BigInteger, - // may create ephemeral data while computing gcd - array[replaceIndex] = array[replaceIndex].gcd(array[deriveIndex]); - break; - case 3,4: - // creates new old BigInteger, releases old BigInteger - array[replaceIndex] = array[replaceIndex].multiply(array[deriveIndex]); - break; - case 5,6,7: + case 0,1,2 -> { + // creates new BitSet, releases old BitSet, + // create ephemeral data while computing + BitSet result = (BitSet) array[deriveIndex].clone(); + for (int j=0; j<10; j++) { + result = (BitSet) array[deriveIndex].clone(); + } + array[replaceIndex] = result; + } + case 3,4 -> { + // creates new BitSet, releases old BitSet + BitSet result = (BitSet) array[deriveIndex].clone(); + array[replaceIndex] = result; + } + case 5,6,7 -> { // do nothing, let all objects in the array age to increase pressure on old generation - break; + } } } } @@ -93,6 +97,8 @@ public class TestOldGrowthTriggers { } testOld("-Xlog:gc", + "-XX:ConcGCThreads=1", + "-XX:ParallelGCThreads=1", "-Xms96m", "-Xmx96m", "-XX:+UnlockDiagnosticVMOptions", @@ -108,6 +114,8 @@ public class TestOldGrowthTriggers { ); testOld("-Xlog:gc", + "-XX:ConcGCThreads=1", + "-XX:ParallelGCThreads=1", "-Xms96m", "-Xmx96m", "-XX:+UnlockDiagnosticVMOptions",