view src/hotspot/share/gc/g1/g1StringDedupStat.cpp @ 49273:216c2aabbf1f

8196602: Change HeapRegionClosure to comply to naming conventions Reviewed-by: kbarrett, sjohanss
author tschatzl
date Fri, 09 Feb 2018 11:51:40 +0100
parents 71c04702a3d5
children fa727a4d7934
line wrap: on
line source
/*
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
 * 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.
 *
 */

#include "precompiled.hpp"
#include "gc/g1/g1StringDedupStat.hpp"
#include "logging/log.hpp"

G1StringDedupStat::G1StringDedupStat() :
  _inspected(0),
  _skipped(0),
  _hashed(0),
  _known(0),
  _new(0),
  _new_bytes(0),
  _deduped(0),
  _deduped_bytes(0),
  _deduped_young(0),
  _deduped_young_bytes(0),
  _deduped_old(0),
  _deduped_old_bytes(0),
  _idle(0),
  _exec(0),
  _block(0),
  _start_concurrent(0.0),
  _end_concurrent(0.0),
  _start_phase(0.0),
  _idle_elapsed(0.0),
  _exec_elapsed(0.0),
  _block_elapsed(0.0) {
}

void G1StringDedupStat::add(const G1StringDedupStat& stat) {
  _inspected           += stat._inspected;
  _skipped             += stat._skipped;
  _hashed              += stat._hashed;
  _known               += stat._known;
  _new                 += stat._new;
  _new_bytes           += stat._new_bytes;
  _deduped             += stat._deduped;
  _deduped_bytes       += stat._deduped_bytes;
  _deduped_young       += stat._deduped_young;
  _deduped_young_bytes += stat._deduped_young_bytes;
  _deduped_old         += stat._deduped_old;
  _deduped_old_bytes   += stat._deduped_old_bytes;
  _idle                += stat._idle;
  _exec                += stat._exec;
  _block               += stat._block;
  _idle_elapsed        += stat._idle_elapsed;
  _exec_elapsed        += stat._exec_elapsed;
  _block_elapsed       += stat._block_elapsed;
}

void G1StringDedupStat::print_start(const G1StringDedupStat& last_stat) {
  log_info(gc, stringdedup)(
     "Concurrent String Deduplication (" G1_STRDEDUP_TIME_FORMAT ")",
     G1_STRDEDUP_TIME_PARAM(last_stat._start_concurrent));
}

void G1StringDedupStat::print_end(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {
  double total_deduped_bytes_percent = 0.0;

  if (total_stat._new_bytes > 0) {
    // Avoid division by zero
    total_deduped_bytes_percent = percent_of(total_stat._deduped_bytes, total_stat._new_bytes);
  }

  log_info(gc, stringdedup)(
    "Concurrent String Deduplication "
    G1_STRDEDUP_BYTES_FORMAT_NS "->" G1_STRDEDUP_BYTES_FORMAT_NS "(" G1_STRDEDUP_BYTES_FORMAT_NS ") "
    "avg " G1_STRDEDUP_PERCENT_FORMAT_NS " "
    "(" G1_STRDEDUP_TIME_FORMAT ", " G1_STRDEDUP_TIME_FORMAT ") " G1_STRDEDUP_TIME_FORMAT_MS,
    G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes),
    G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes - last_stat._deduped_bytes),
    G1_STRDEDUP_BYTES_PARAM(last_stat._deduped_bytes),
    total_deduped_bytes_percent,
    G1_STRDEDUP_TIME_PARAM(last_stat._start_concurrent),
    G1_STRDEDUP_TIME_PARAM(last_stat._end_concurrent),
    G1_STRDEDUP_TIME_PARAM_MS(last_stat._exec_elapsed));
}

void G1StringDedupStat::print_statistics(const G1StringDedupStat& stat, bool total) {
  double skipped_percent             = percent_of(stat._skipped, stat._inspected);
  double hashed_percent              = percent_of(stat._hashed, stat._inspected);
  double known_percent               = percent_of(stat._known, stat._inspected);
  double new_percent                 = percent_of(stat._new, stat._inspected);
  double deduped_percent             = percent_of(stat._deduped, stat._new);
  double deduped_bytes_percent       = percent_of(stat._deduped_bytes, stat._new_bytes);
  double deduped_young_percent       = percent_of(stat._deduped_young, stat._deduped);
  double deduped_young_bytes_percent = percent_of(stat._deduped_young_bytes, stat._deduped_bytes);
  double deduped_old_percent         = percent_of(stat._deduped_old, stat._deduped);
  double deduped_old_bytes_percent   = percent_of(stat._deduped_old_bytes, stat._deduped_bytes);

  if (total) {
    log_debug(gc, stringdedup)(
      "  Total Exec: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS
      ", Idle: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS
      ", Blocked: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS,
      stat._exec, G1_STRDEDUP_TIME_PARAM_MS(stat._exec_elapsed),
      stat._idle, G1_STRDEDUP_TIME_PARAM_MS(stat._idle_elapsed),
      stat._block, G1_STRDEDUP_TIME_PARAM_MS(stat._block_elapsed));
  } else {
    log_debug(gc, stringdedup)(
      "  Last Exec: " G1_STRDEDUP_TIME_FORMAT_MS
      ", Idle: " G1_STRDEDUP_TIME_FORMAT_MS
      ", Blocked: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS,
      G1_STRDEDUP_TIME_PARAM_MS(stat._exec_elapsed),
      G1_STRDEDUP_TIME_PARAM_MS(stat._idle_elapsed),
      stat._block, G1_STRDEDUP_TIME_PARAM_MS(stat._block_elapsed));
  }
  log_debug(gc, stringdedup)("    Inspected:    " G1_STRDEDUP_OBJECTS_FORMAT, stat._inspected);
  log_debug(gc, stringdedup)("      Skipped:    " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", stat._skipped, skipped_percent);
  log_debug(gc, stringdedup)("      Hashed:     " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", stat._hashed, hashed_percent);
  log_debug(gc, stringdedup)("      Known:      " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", stat._known, known_percent);
  log_debug(gc, stringdedup)("      New:        " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT,
                             stat._new, new_percent, G1_STRDEDUP_BYTES_PARAM(stat._new_bytes));
  log_debug(gc, stringdedup)("    Deduplicated: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")",
                             stat._deduped, deduped_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_bytes), deduped_bytes_percent);
  log_debug(gc, stringdedup)("      Young:      " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")",
                             stat._deduped_young, deduped_young_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_young_bytes), deduped_young_bytes_percent);
  log_debug(gc, stringdedup)("      Old:        " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")",
                             stat._deduped_old, deduped_old_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_old_bytes), deduped_old_bytes_percent);
}