diff options
author | 2022-12-17 16:40:19 -0800 | |
---|---|---|
committer | 2022-12-19 16:47:31 +0000 | |
commit | 4a3a8044c18e8a82bcfd7825a6a99be3aa86342c (patch) | |
tree | 99792f58596f24ec4bb465b7cc5a7492f4ed6e93 | |
parent | 1aaa9d4824f34ad8a2c70ab7c93598ef85e7443a (diff) |
Speed up 080-oom-throw
Change the heap filling algorithm to use fewer size classes.
Allocating more objects is much cheaper than running out of memory
more often.
time art/test/run-test --host 080-oom-throw
Speeds up from about 16 seconds to 12 seconds elapsed time,
including any script overhead.
Bug: 262517556
Test: Time test on host, Treehugger
Change-Id: Ifcdb90cbf493f5fded0e5a573268edb7b01a1b01
-rw-r--r-- | test/080-oom-throw/src/Main.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/test/080-oom-throw/src/Main.java b/test/080-oom-throw/src/Main.java index cd36eff160..c9fd3610ff 100644 --- a/test/080-oom-throw/src/Main.java +++ b/test/080-oom-throw/src/Main.java @@ -55,12 +55,20 @@ public class Main { private static int exhaustJavaHeap(Object[] data, int index, int size) { Runtime.getRuntime().gc(); - while (index != data.length && size != 0) { + while (index != data.length) { try { data[index] = new byte[size]; ++index; } catch (OutOfMemoryError oome) { - size /= 2; + // Rapidly shrink the object size to fill any remaining space. + // Use few different sizes, since detecting out-of-memory is slow. + if (size >= 32) { + size /= 32; + } else if (size > 1) { + size = 1; + } else { + break; + } } } return index; |