From a48f6f1d64bf4606c6f100eb6dae674409d184cd Mon Sep 17 00:00:00 2001 From: Lokesh Gidra Date: Wed, 23 Sep 2020 09:36:01 -0700 Subject: Replace inlined string allocations to loop in 096-array-copy-concurrent Replacing inlined string allocations with a loop is expected to reduce the number of GC invocations in case of GC-stress mode. Hopefully, this will fix the timeout that is being observed. Bug: 169242013 Test: art/test/testrunner/testrunner.py --host -t 096-array-copy-concurrent Change-Id: Ib5c4130a5369749f1c28496cc2a1849f776a45be --- test/096-array-copy-concurrent-gc/src/Main.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'test/096-array-copy-concurrent-gc/src') diff --git a/test/096-array-copy-concurrent-gc/src/Main.java b/test/096-array-copy-concurrent-gc/src/Main.java index 3cf791a555..eddde11b44 100644 --- a/test/096-array-copy-concurrent-gc/src/Main.java +++ b/test/096-array-copy-concurrent-gc/src/Main.java @@ -44,6 +44,15 @@ public class Main { Object [] array = new Object[8000]; + void allocateFourStrings() { + for (int i = 0; i < 4; i++) { + String str = new String("Creating some garbage" + Math.random()); + if (str.length() < 22) { + System.out.println("bad length"); + } + } + } + void stressArray(boolean doLog) { // We want many references in the array // We also want elements close to each other to have large @@ -63,20 +72,14 @@ public class Main { Object obj = array[array.length - 1]; System.arraycopy(array, 0, array, 1, array.length - 1); array[0] = obj; - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); + allocateFourStrings(); } for (int j = 0; j < array.length; j++) { Object obj = array[0]; System.arraycopy(array, 1, array, 0, array.length - 1); array[array.length - 1] = obj; - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); + allocateFourStrings(); } if (doLog) { -- cgit v1.2.3-59-g8ed1b