-XX:+StressCodeBuffers

Andrew Haley aph-open at littlepinkcloud.com
Tue May 17 08:54:25 UTC 2022


Working on 8272094: compiler/codecache/TestStressCodeBuffers.java
crashes..., I found that it took so long to reproduce the problem,
even with many parallel runs, that I gave up. Even after hours it
didn't show up.

Output from StressCodeBuffers looks like this:

StressCodeBuffers: have expanded 128 times
StressCodeBuffers: have expanded 256 times
StressCodeBuffers: have expanded 512 times
StressCodeBuffers: have expanded 1024 times
StressCodeBuffers: have expanded 2048 times

Each time this message is printed, a code buffer allocation fails. So
it only tests code buffer allocation failure a few times.

I changed the logic (patch below) to make codeBuffer allocation fail
much more frequently, every 40 times, and "Boom!" I reproduced the
bug immediately. Every run, in fact.

So, my question is: why is -XX:+StressCodeBuffers so very gentle? It
seems to me like it's not even trying to stress the system.

diff --git a/src/hotspot/share/asm/codeBuffer.cpp b/src/hotspot/share/asm/codeBuffer.cpp
index ddd946d7542..c74ba21cf63 100644
--- a/src/hotspot/share/asm/codeBuffer.cpp
+++ b/src/hotspot/share/asm/codeBuffer.cpp
@@ -837,7 +837,8 @@ void CodeBuffer::expand(CodeSection* which_cs, csize_t amount) {
    if (StressCodeBuffers && blob() != NULL) {
      static int expand_count = 0;
      if (expand_count >= 0)  expand_count += 1;
-    if (expand_count > 100 && is_power_of_2(expand_count)) {
+    if (expand_count > 100 && // is_power_of_2(expand_count)
+        expand_count % 40 == 0) {
        tty->print_cr("StressCodeBuffers: have expanded %d times", expand_count);
        // simulate an occasional allocation failure:
        free_blob();

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



More information about the hotspot-compiler-dev mailing list