src/hotspot/share/gc/shared/stringdedup/stringDedupStat.hpp
author zgu
Thu, 14 Jun 2018 09:59:21 -0400
changeset 50574 fa727a4d7934
child 53244 9807daeb47c4
permissions -rw-r--r--
8203641: Refactor String Deduplication into shared Summary: Allows string deduplication to be shared among different collectors Reviewed-by: tschatzl, rkennke
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50574
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     1
/*
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     4
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     8
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    13
 * accompanied this code).
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    14
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    18
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    21
 * questions.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    22
 *
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    23
 */
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    24
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_STRINGDEDUP_STRINGDEDUPSTAT_HPP
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    26
#define SHARE_VM_GC_SHARED_STRINGDEDUP_STRINGDEDUPSTAT_HPP
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    27
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    28
#include "memory/allocation.hpp"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    29
#include "runtime/os.hpp"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    30
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    31
// Macros for GC log output formating
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    32
#define STRDEDUP_OBJECTS_FORMAT         UINTX_FORMAT_W(12)
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    33
#define STRDEDUP_TIME_FORMAT            "%.3fs"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    34
#define STRDEDUP_TIME_PARAM(time)       (time)
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    35
#define STRDEDUP_TIME_FORMAT_MS         "%.3fms"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    36
#define STRDEDUP_TIME_PARAM_MS(time)    ((time) * MILLIUNITS)
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    37
#define STRDEDUP_PERCENT_FORMAT         "%5.1f%%"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    38
#define STRDEDUP_PERCENT_FORMAT_NS      "%.1f%%"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    39
#define STRDEDUP_BYTES_FORMAT           "%8.1f%s"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    40
#define STRDEDUP_BYTES_FORMAT_NS        "%.1f%s"
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    41
#define STRDEDUP_BYTES_PARAM(bytes)     byte_size_in_proper_unit((double)(bytes)), proper_unit_for_byte_size((bytes))
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    42
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    43
//
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    44
// Statistics gathered by the deduplication thread.
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    45
//
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    46
class StringDedupStat : public CHeapObj<mtGC> {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    47
protected:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    48
  // Counters
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    49
  uintx  _inspected;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    50
  uintx  _skipped;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    51
  uintx  _hashed;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    52
  uintx  _known;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    53
  uintx  _new;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    54
  uintx  _new_bytes;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    55
  uintx  _deduped;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    56
  uintx  _deduped_bytes;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    57
  uintx  _idle;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    58
  uintx  _exec;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    59
  uintx  _block;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    60
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    61
  // Time spent by the deduplication thread in different phases
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    62
  double _start_concurrent;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    63
  double _end_concurrent;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    64
  double _start_phase;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    65
  double _idle_elapsed;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    66
  double _exec_elapsed;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    67
  double _block_elapsed;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    68
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    69
public:
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    70
  StringDedupStat();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    71
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    72
  void inc_inspected() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    73
    _inspected++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    74
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    75
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    76
  void inc_skipped() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    77
    _skipped++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    78
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    79
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    80
  void inc_hashed() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    81
    _hashed++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    82
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    83
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    84
  void inc_known() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    85
    _known++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    86
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    87
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    88
  void inc_new(uintx bytes) {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    89
    _new++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    90
    _new_bytes += bytes;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    91
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    92
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    93
  virtual void deduped(oop obj, uintx bytes) {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    94
    _deduped++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    95
    _deduped_bytes += bytes;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    96
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    97
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    98
  void mark_idle() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
    99
    _start_phase = os::elapsedTime();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   100
    _idle++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   101
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   102
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   103
  void mark_exec() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   104
    double now = os::elapsedTime();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   105
    _idle_elapsed = now - _start_phase;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   106
    _start_phase = now;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   107
    _start_concurrent = now;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   108
    _exec++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   109
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   110
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   111
  void mark_block() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   112
    double now = os::elapsedTime();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   113
    _exec_elapsed += now - _start_phase;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   114
    _start_phase = now;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   115
    _block++;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   116
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   117
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   118
  void mark_unblock() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   119
    double now = os::elapsedTime();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   120
    _block_elapsed += now - _start_phase;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   121
    _start_phase = now;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   122
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   123
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   124
  void mark_done() {
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   125
    double now = os::elapsedTime();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   126
    _exec_elapsed += now - _start_phase;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   127
    _end_concurrent = now;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   128
  }
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   129
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   130
  virtual void reset();
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   131
  virtual void add(const StringDedupStat* const stat);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   132
  virtual void print_statistics(bool total) const;
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   133
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   134
  static void print_start(const StringDedupStat* last_stat);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   135
  static void print_end(const StringDedupStat* last_stat, const StringDedupStat* total_stat);
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   136
};
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   137
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   138
#endif // SHARE_VM_GC_SHARED_STRINGDEDUP_STRINGDEDUPSTAT_HPP
fa727a4d7934 8203641: Refactor String Deduplication into shared
zgu
parents:
diff changeset
   139