src/hotspot/share/gc/g1/g1StringDedupStat.cpp
author tschatzl
Wed, 17 Jul 2019 16:33:19 +0200
changeset 55722 5ee183a90e65
parent 50574 fa727a4d7934
permissions -rw-r--r--
8227084: Add timing information for merge heap root preparation Reviewed-by: sangheki, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     1
/*
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     4
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     8
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    13
 * accompanied this code).
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    14
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    18
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    21
 * questions.
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    22
 *
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    23
 */
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    24
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    25
#include "precompiled.hpp"
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    26
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    27
#include "gc/g1/g1CollectedHeap.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 23472
diff changeset
    28
#include "gc/g1/g1StringDedupStat.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 31592
diff changeset
    29
#include "logging/log.hpp"
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    30
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    31
G1StringDedupStat::G1StringDedupStat() : StringDedupStat(),
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    32
  _deduped_young(0),
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    33
  _deduped_young_bytes(0),
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    34
  _deduped_old(0),
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    35
  _deduped_old_bytes(0),
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    36
  _heap(G1CollectedHeap::heap()) {
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    37
}
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    38
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    39
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    40
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    41
void G1StringDedupStat::deduped(oop obj, uintx bytes) {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    42
  StringDedupStat::deduped(obj, bytes);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    43
  if (_heap->is_in_young(obj)) {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    44
    _deduped_young ++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    45
    _deduped_young_bytes += bytes;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    46
  } else {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    47
    _deduped_old ++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    48
    _deduped_old_bytes += bytes;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    49
  }
39690
09a3ee292336 8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents: 39287
diff changeset
    50
}
09a3ee292336 8159974: G1 String deduplication logging not aligned with the rest of G1
pliden
parents: 39287
diff changeset
    51
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    52
void G1StringDedupStat::add(const StringDedupStat* const stat) {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    53
  StringDedupStat::add(stat);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    54
  const G1StringDedupStat* const g1_stat = (const G1StringDedupStat* const)stat;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    55
  _deduped_young += g1_stat->_deduped_young;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    56
  _deduped_young_bytes += g1_stat->_deduped_young_bytes;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    57
  _deduped_old += g1_stat->_deduped_old;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    58
  _deduped_old_bytes += g1_stat->_deduped_old_bytes;
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    59
}
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    60
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    61
void G1StringDedupStat::print_statistics(bool total) const {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    62
  StringDedupStat::print_statistics(total);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    63
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    64
  double deduped_young_percent       = percent_of(_deduped_young, _deduped);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    65
  double deduped_young_bytes_percent = percent_of(_deduped_young_bytes, _deduped_bytes);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    66
  double deduped_old_percent         = percent_of(_deduped_old, _deduped);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    67
  double deduped_old_bytes_percent   = percent_of(_deduped_old_bytes, _deduped_bytes);
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    68
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    69
  log_debug(gc, stringdedup)("      Young:      " STRDEDUP_OBJECTS_FORMAT "(" STRDEDUP_PERCENT_FORMAT ") " STRDEDUP_BYTES_FORMAT "(" STRDEDUP_PERCENT_FORMAT ")",
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    70
                             _deduped_young, deduped_young_percent, STRDEDUP_BYTES_PARAM(_deduped_young_bytes), deduped_young_bytes_percent);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    71
  log_debug(gc, stringdedup)("      Old:        " STRDEDUP_OBJECTS_FORMAT "(" STRDEDUP_PERCENT_FORMAT ") " STRDEDUP_BYTES_FORMAT "(" STRDEDUP_PERCENT_FORMAT ")",
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    72
                             _deduped_old, deduped_old_percent, STRDEDUP_BYTES_PARAM(_deduped_old_bytes), deduped_old_bytes_percent);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    73
23472
35e93890ed88 8029075: String deduplication in G1
pliden
parents:
diff changeset
    74
}
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    75
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    76
void G1StringDedupStat::reset() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    77
  StringDedupStat::reset();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    78
  _deduped_young = 0;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    79
  _deduped_young_bytes = 0;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    80
  _deduped_old = 0;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    81
  _deduped_old_bytes = 0;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents: 47679
diff changeset
    82
}