Print heap counters occasionally epsilon-gc-branch
authorshade
Fri, 08 Dec 2017 13:45:22 +0100
branchepsilon-gc-branch
changeset 55979 669f8c047c9c
parent 55976 be6a0c9587da
child 55980 67d289ae67f5
Print heap counters occasionally
src/hotspot/share/gc/epsilon/epsilonHeap.cpp
src/hotspot/share/gc/epsilon/epsilonHeap.hpp
src/hotspot/share/gc/epsilon/epsilon_globals.hpp
test/hotspot/jtreg/gc/epsilon/TestPrintHeapSteps.java
test/hotspot/jtreg/gc/epsilon/TestUpdateCountersSteps.java
--- a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp	Thu Dec 07 13:23:41 2017 +0100
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp	Fri Dec 08 13:45:22 2017 +0100
@@ -50,6 +50,10 @@
 
   _monitoring_support = new EpsilonMonitoringSupport(this);
   _last_counter_update = 0;
+  _last_heap_print = 0;
+
+  _step_counter_update = MIN2<size_t>(max_byte_size / 16, EpsilonUpdateCountersStep);
+  _step_heap_print = (EpsilonPrintHeapStep == 0) ? SIZE_MAX : (max_byte_size / EpsilonPrintHeapStep);
 
   if (init_byte_size != max_byte_size) {
     log_info(gc)("Initialized with " SIZE_FORMAT "M heap, resizeable to up to " SIZE_FORMAT "M heap with " SIZE_FORMAT "M steps",
@@ -130,10 +134,17 @@
   }
 
   size_t used = _space->used();
-  if (used - _last_counter_update >= 1024 * 1024) {
+  if (used - _last_counter_update >= _step_counter_update) {
     _last_counter_update = used;
     _monitoring_support->update_counters();
   }
+
+  if (used - _last_heap_print >= _step_heap_print) {
+    log_info(gc)("Heap: " SIZE_FORMAT "M reserved, " SIZE_FORMAT "M committed, " SIZE_FORMAT "M used",
+                 max_capacity() / M, capacity() / M, used / M);
+    _last_heap_print = used;
+  }
+
   return res;
 }
 
--- a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp	Thu Dec 07 13:23:41 2017 +0100
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp	Fri Dec 08 13:45:22 2017 +0100
@@ -42,6 +42,9 @@
   VirtualSpace _virtual_space;
   size_t _max_tlab_size;
   size_t _last_counter_update;
+  size_t _last_heap_print;
+  size_t _step_counter_update;
+  size_t _step_heap_print;
 public:
   EpsilonHeap(EpsilonCollectorPolicy* p) :
           _policy(p),
--- a/src/hotspot/share/gc/epsilon/epsilon_globals.hpp	Thu Dec 07 13:23:41 2017 +0100
+++ b/src/hotspot/share/gc/epsilon/epsilon_globals.hpp	Fri Dec 08 13:45:22 2017 +0100
@@ -44,6 +44,17 @@
                  constraint, \
                  writeable) \
                                                                             \
+  experimental(size_t, EpsilonPrintHeapStep, 100,                           \
+          "Print heap occupancy stats with this number of steps. "          \
+          "0 turns the printing off. ")                                     \
+          range(0, max_intx)                                                \
+                                                                            \
+  experimental(size_t, EpsilonUpdateCountersStep, 1 * M,                    \
+          "Update heap heap occupancy counters after allocating this much " \
+          "memory. Higher values would make allocations faster at "         \
+          "the expense of lower resolution in heap counters. ")             \
+          range(1, max_intx)                                                \
+                                                                            \
   experimental(size_t, EpsilonMaxTLABSize, 4 * M,                           \
           "Max TLAB size to use with Epsilon GC. Larger value improves "    \
           "performance at the expense of per-thread memory waste. This "    \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestPrintHeapSteps.java	Fri Dec 08 13:45:22 2017 +0100
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestPrintSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonPrintHeapSteps=0    TestPrintHeapSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonPrintHeapSteps=1    TestPrintHeapSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonPrintHeapSteps=1000 TestPrintHeapSteps
+ */
+
+public class TestPrintHeapSteps {
+  public static void main(String[] args) throws Exception {
+    System.out.println("Hello World");
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/gc/epsilon/TestUpdateCountersSteps.java	Fri Dec 08 13:45:22 2017 +0100
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=1    TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=10   TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=100  TestUpdateCountersSteps
+ * @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+UseEpsilonGC -Xlog:gc -XX:EpsilonTestUpdateCountersSteps=1000 TestUpdateCountersSteps
+ */
+
+public class TestUpdateCountersSteps {
+  public static void main(String[] args) throws Exception {
+    System.out.println("Hello World");
+  }
+}