changeset 55828:d9a157f6fd71

8224847: gc/stress/TestReclaimStringsLeaksMemory.java fails with reserved greater than expected Summary: Rehash threshold was too low for StringTable, and rehashed size table was too large. Reviewed-by: rehn, gziemski
author coleenp
date Tue, 11 Jun 2019 07:31:47 -0400
parents 27e810f1f8a3
children 03af124751f5
files src/hotspot/share/classfile/stringTable.cpp src/hotspot/share/classfile/symbolTable.cpp test/hotspot/jtreg/ProblemList.txt test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java
diffstat 4 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/stringTable.cpp	Tue Jun 11 08:03:29 2019 -0400
+++ b/src/hotspot/share/classfile/stringTable.cpp	Tue Jun 11 07:31:47 2019 -0400
@@ -58,8 +58,8 @@
 const double PREF_AVG_LIST_LEN = 2.0;
 // 2^24 is max size
 const size_t END_SIZE = 24;
-// If a chain gets to 32 something might be wrong
-const size_t REHASH_LEN = 32;
+// If a chain gets to 100 something might be wrong
+const size_t REHASH_LEN = 100;
 // If we have as many dead items as 50% of the number of bucket
 const double CLEAN_DEAD_HIGH_WATER_MARK = 0.5;
 
@@ -496,8 +496,9 @@
     return false;
   }
 
-  // We use max size
-  StringTableHash* new_table = new StringTableHash(END_SIZE, END_SIZE, REHASH_LEN);
+  // We use current size, not max size.
+  size_t new_size = _local_table->get_size_log2(Thread::current());
+  StringTableHash* new_table = new StringTableHash(new_size, END_SIZE, REHASH_LEN);
   // Use alt hash from now on
   _alt_hash = true;
   if (!_local_table->try_move_nodes_to(Thread::current(), new_table)) {
--- a/src/hotspot/share/classfile/symbolTable.cpp	Tue Jun 11 08:03:29 2019 -0400
+++ b/src/hotspot/share/classfile/symbolTable.cpp	Tue Jun 11 07:31:47 2019 -0400
@@ -267,7 +267,7 @@
   // all symbols from the dynamic table
   SymbolsDo sd(cl);
   if (!_local_table->try_scan(Thread::current(), sd)) {
-    log_info(stringtable)("symbols_do unavailable at this moment");
+    log_info(symboltable)("symbols_do unavailable at this moment");
   }
 }
 
@@ -557,7 +557,7 @@
   Thread* thr = Thread::current();
   VerifySymbols vs;
   if (!_local_table->try_scan(thr, vs)) {
-    log_info(stringtable)("verify unavailable at this moment");
+    log_info(symboltable)("verify unavailable at this moment");
   }
 }
 
@@ -763,8 +763,9 @@
     return false;
   }
 
-  // We use max size
-  SymbolTableHash* new_table = new SymbolTableHash(END_SIZE, END_SIZE, REHASH_LEN);
+  // We use current size
+  size_t new_size = _local_table->get_size_log2(Thread::current());
+  SymbolTableHash* new_table = new SymbolTableHash(new_size, END_SIZE, REHASH_LEN);
   // Use alt hash from now on
   _alt_hash = true;
   if (!_local_table->try_move_nodes_to(Thread::current(), new_table)) {
--- a/test/hotspot/jtreg/ProblemList.txt	Tue Jun 11 08:03:29 2019 -0400
+++ b/test/hotspot/jtreg/ProblemList.txt	Tue Jun 11 07:31:47 2019 -0400
@@ -77,7 +77,6 @@
 gc/stress/gclocker/TestGCLockerWithG1.java 8180622 generic-all
 gc/stress/TestJNIBlockFullGC/TestJNIBlockFullGC.java 8192647 generic-all
 gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8193639 solaris-all
-gc/stress/TestReclaimStringsLeaksMemory.java 8224847 generic-all
 
 #############################################################################
 
--- a/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java	Tue Jun 11 08:03:29 2019 -0400
+++ b/test/hotspot/jtreg/gc/stress/TestReclaimStringsLeaksMemory.java	Tue Jun 11 07:31:47 2019 -0400
@@ -57,7 +57,7 @@
     public static void main(String[] args) throws Exception {
         ArrayList<String> baseargs = new ArrayList<>(Arrays.asList("-Xms256M",
                                                                    "-Xmx256M",
-                                                                   "-Xlog:gc*",
+                                                                   "-Xlog:gc*,stringtable*=debug:gc.log",
                                                                    "-XX:NativeMemoryTracking=summary",
                                                                    "-XX:+UnlockDiagnosticVMOptions",
                                                                    "-XX:+PrintNMTStatistics" ));
@@ -95,9 +95,19 @@
                     lastString = (BaseName + i).intern();
                 }
                 if (++iterations % 5 == 0) {
-                   System.gc();
+                    System.gc();
                 }
             }
+            // Do one last GC and sleep to give ServiceThread a chance to run.
+            System.out.println("One last gc");
+            System.gc();
+            for (int i = 0; i < 100; i++) {
+                try {
+                    Thread.sleep(10);
+                } catch (InterruptedException ex) {
+                }
+            }
+            System.out.println("End of test");
         }
     }
 }