< prev index next >

src/hotspot/share/gc/shared/gcTraceTime.inline.hpp

Print this page
rev 56527 : 8232100: GC timings should use proper units for heap sizes
Reviewed-by: XXX


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_SHARED_GCTRACETIME_INLINE_HPP
  26 #define SHARE_GC_SHARED_GCTRACETIME_INLINE_HPP
  27 
  28 #include "gc/shared/collectedHeap.hpp"
  29 #include "gc/shared/gcTimer.hpp"
  30 #include "gc/shared/gcTrace.hpp"
  31 #include "gc/shared/gcTraceTime.hpp"
  32 #include "logging/log.hpp"
  33 #include "logging/logStream.hpp"
  34 #include "memory/universe.hpp"

  35 #include "utilities/ticks.hpp"
  36 
  37 #define LOG_STOP_HEAP_FORMAT SIZE_FORMAT "M->" SIZE_FORMAT "M("  SIZE_FORMAT "M)"
  38 
  39 inline void GCTraceTimeImpl::log_start(jlong start_counter) {
  40   if (_out_start.is_enabled()) {
  41     LogStream out(_out_start);
  42 
  43     out.print("%s", _title);
  44     if (_gc_cause != GCCause::_no_gc) {
  45       out.print(" (%s)", GCCause::to_string(_gc_cause));
  46     }
  47     out.cr();
  48   }
  49 }
  50 
  51 inline void GCTraceTimeImpl::log_stop(jlong start_counter, jlong stop_counter) {
  52   double duration_in_ms = TimeHelper::counter_to_millis(stop_counter - start_counter);
  53   double start_time_in_secs = TimeHelper::counter_to_seconds(start_counter);
  54   double stop_time_in_secs = TimeHelper::counter_to_seconds(stop_counter);
  55 
  56   LogStream out(_out_stop);
  57 
  58   out.print("%s", _title);
  59 
  60   if (_gc_cause != GCCause::_no_gc) {
  61     out.print(" (%s)", GCCause::to_string(_gc_cause));
  62   }
  63 
  64   if (_heap_usage_before != SIZE_MAX) {
  65     CollectedHeap* heap = Universe::heap();
  66     size_t used_before_m = _heap_usage_before / M;
  67     size_t used_m = heap->used() / M;
  68     size_t capacity_m = heap->capacity() / M;
  69     out.print(" " LOG_STOP_HEAP_FORMAT, used_before_m, used_m, capacity_m);



  70   }
  71 
  72   out.print_cr(" %.3fms", duration_in_ms);
  73 }
  74 
  75 inline void GCTraceTimeImpl::time_stamp(Ticks& ticks) {
  76   if (_enabled || _timer != NULL) {
  77     ticks.stamp();
  78   }
  79 }
  80 
  81 inline GCTraceTimeImpl::GCTraceTimeImpl(LogTargetHandle out_start, LogTargetHandle out_stop, const char* title, GCTimer* timer, GCCause::Cause gc_cause, bool log_heap_usage) :
  82   _out_start(out_start),
  83   _out_stop(out_stop),
  84   _enabled(out_stop.is_enabled()),
  85   _start_ticks(),
  86   _title(title),
  87   _gc_cause(gc_cause),
  88   _timer(timer),
  89   _heap_usage_before(SIZE_MAX) {




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_SHARED_GCTRACETIME_INLINE_HPP
  26 #define SHARE_GC_SHARED_GCTRACETIME_INLINE_HPP
  27 
  28 #include "gc/shared/collectedHeap.hpp"
  29 #include "gc/shared/gcTimer.hpp"
  30 #include "gc/shared/gcTrace.hpp"
  31 #include "gc/shared/gcTraceTime.hpp"
  32 #include "logging/log.hpp"
  33 #include "logging/logStream.hpp"
  34 #include "memory/universe.hpp"
  35 #include "utilities/globalDefinitions.hpp"
  36 #include "utilities/ticks.hpp"
  37 


  38 inline void GCTraceTimeImpl::log_start(jlong start_counter) {
  39   if (_out_start.is_enabled()) {
  40     LogStream out(_out_start);
  41 
  42     out.print("%s", _title);
  43     if (_gc_cause != GCCause::_no_gc) {
  44       out.print(" (%s)", GCCause::to_string(_gc_cause));
  45     }
  46     out.cr();
  47   }
  48 }
  49 
  50 inline void GCTraceTimeImpl::log_stop(jlong start_counter, jlong stop_counter) {
  51   double duration_in_ms = TimeHelper::counter_to_millis(stop_counter - start_counter);
  52   double start_time_in_secs = TimeHelper::counter_to_seconds(start_counter);
  53   double stop_time_in_secs = TimeHelper::counter_to_seconds(stop_counter);
  54 
  55   LogStream out(_out_stop);
  56 
  57   out.print("%s", _title);
  58 
  59   if (_gc_cause != GCCause::_no_gc) {
  60     out.print(" (%s)", GCCause::to_string(_gc_cause));
  61   }
  62 
  63   if (_heap_usage_before != SIZE_MAX) {
  64     CollectedHeap* heap = Universe::heap();
  65     size_t used_before = _heap_usage_before;
  66     size_t used = heap->used();
  67     size_t capacity = heap->capacity();
  68     out.print(" " SIZE_FORMAT "%s->" SIZE_FORMAT "%s("  SIZE_FORMAT "%s)",
  69              byte_size_in_proper_unit(used_before), proper_unit_for_byte_size(used_before),
  70              byte_size_in_proper_unit(used),        proper_unit_for_byte_size(used),
  71              byte_size_in_proper_unit(capacity),    proper_unit_for_byte_size(capacity));
  72   }
  73 
  74   out.print_cr(" %.3fms", duration_in_ms);
  75 }
  76 
  77 inline void GCTraceTimeImpl::time_stamp(Ticks& ticks) {
  78   if (_enabled || _timer != NULL) {
  79     ticks.stamp();
  80   }
  81 }
  82 
  83 inline GCTraceTimeImpl::GCTraceTimeImpl(LogTargetHandle out_start, LogTargetHandle out_stop, const char* title, GCTimer* timer, GCCause::Cause gc_cause, bool log_heap_usage) :
  84   _out_start(out_start),
  85   _out_stop(out_stop),
  86   _enabled(out_stop.is_enabled()),
  87   _start_ticks(),
  88   _title(title),
  89   _gc_cause(gc_cause),
  90   _timer(timer),
  91   _heap_usage_before(SIZE_MAX) {


< prev index next >