1 /* 2 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 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 #include "precompiled.hpp" 26 #include "gc/g1/g1StringDedupStat.hpp" 27 #include "logging/log.hpp" 28 29 G1StringDedupStat::G1StringDedupStat() : 30 _inspected(0), 31 _skipped(0), 32 _hashed(0), 33 _known(0), 34 _new(0), 35 _new_bytes(0), 36 _deduped(0), 37 _deduped_bytes(0), 38 _deduped_young(0), 39 _deduped_young_bytes(0), 40 _deduped_old(0), 41 _deduped_old_bytes(0), 42 _idle(0), 43 _exec(0), 44 _block(0), 45 _start_concurrent(0.0), 46 _end_concurrent(0.0), 47 _start_phase(0.0), 48 _idle_elapsed(0.0), 49 _exec_elapsed(0.0), 50 _block_elapsed(0.0) { 51 } 52 53 void G1StringDedupStat::add(const G1StringDedupStat& stat) { 54 _inspected += stat._inspected; 55 _skipped += stat._skipped; 56 _hashed += stat._hashed; 57 _known += stat._known; 58 _new += stat._new; 59 _new_bytes += stat._new_bytes; 60 _deduped += stat._deduped; 61 _deduped_bytes += stat._deduped_bytes; 62 _deduped_young += stat._deduped_young; 63 _deduped_young_bytes += stat._deduped_young_bytes; 64 _deduped_old += stat._deduped_old; 65 _deduped_old_bytes += stat._deduped_old_bytes; 66 _idle += stat._idle; 67 _exec += stat._exec; 68 _block += stat._block; 69 _idle_elapsed += stat._idle_elapsed; 70 _exec_elapsed += stat._exec_elapsed; 71 _block_elapsed += stat._block_elapsed; 72 } 73 74 void G1StringDedupStat::print_start(const G1StringDedupStat& last_stat) { 75 log_info(gc, stringdedup)( 76 "Concurrent String Deduplication (" G1_STRDEDUP_TIME_FORMAT ")", 77 G1_STRDEDUP_TIME_PARAM(last_stat._start_concurrent)); 78 } 79 80 void G1StringDedupStat::print_end(const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) { 81 double total_deduped_bytes_percent = 0.0; 82 83 if (total_stat._new_bytes > 0) { 84 // Avoid division by zero 85 total_deduped_bytes_percent = percent_of(total_stat._deduped_bytes, total_stat._new_bytes); 86 } 87 88 log_info(gc, stringdedup)( 89 "Concurrent String Deduplication " 90 G1_STRDEDUP_BYTES_FORMAT_NS "->" G1_STRDEDUP_BYTES_FORMAT_NS "(" G1_STRDEDUP_BYTES_FORMAT_NS ") " 91 "avg " G1_STRDEDUP_PERCENT_FORMAT_NS " " 92 "(" G1_STRDEDUP_TIME_FORMAT ", " G1_STRDEDUP_TIME_FORMAT ") " G1_STRDEDUP_TIME_FORMAT_MS, 93 G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes), 94 G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes - last_stat._deduped_bytes), 95 G1_STRDEDUP_BYTES_PARAM(last_stat._deduped_bytes), 96 total_deduped_bytes_percent, 97 G1_STRDEDUP_TIME_PARAM(last_stat._start_concurrent), 98 G1_STRDEDUP_TIME_PARAM(last_stat._end_concurrent), 99 G1_STRDEDUP_TIME_PARAM_MS(last_stat._exec_elapsed)); 100 } 101 102 void G1StringDedupStat::print_statistics(const G1StringDedupStat& stat, bool total) { 103 double skipped_percent = percent_of(stat._skipped, stat._inspected); 104 double hashed_percent = percent_of(stat._hashed, stat._inspected); 105 double known_percent = percent_of(stat._known, stat._inspected); 106 double new_percent = percent_of(stat._new, stat._inspected); 107 double deduped_percent = percent_of(stat._deduped, stat._new); 108 double deduped_bytes_percent = percent_of(stat._deduped_bytes, stat._new_bytes); 109 double deduped_young_percent = percent_of(stat._deduped_young, stat._deduped); 110 double deduped_young_bytes_percent = percent_of(stat._deduped_young_bytes, stat._deduped_bytes); 111 double deduped_old_percent = percent_of(stat._deduped_old, stat._deduped); 112 double deduped_old_bytes_percent = percent_of(stat._deduped_old_bytes, stat._deduped_bytes); 113 114 if (total) { 115 log_debug(gc, stringdedup)( 116 " Total Exec: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS 117 ", Idle: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS 118 ", Blocked: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS, 119 stat._exec, G1_STRDEDUP_TIME_PARAM_MS(stat._exec_elapsed), 120 stat._idle, G1_STRDEDUP_TIME_PARAM_MS(stat._idle_elapsed), 121 stat._block, G1_STRDEDUP_TIME_PARAM_MS(stat._block_elapsed)); 122 } else { 123 log_debug(gc, stringdedup)( 124 " Last Exec: " G1_STRDEDUP_TIME_FORMAT_MS 125 ", Idle: " G1_STRDEDUP_TIME_FORMAT_MS 126 ", Blocked: " UINTX_FORMAT "/" G1_STRDEDUP_TIME_FORMAT_MS, 127 G1_STRDEDUP_TIME_PARAM_MS(stat._exec_elapsed), 128 G1_STRDEDUP_TIME_PARAM_MS(stat._idle_elapsed), 129 stat._block, G1_STRDEDUP_TIME_PARAM_MS(stat._block_elapsed)); 130 } 131 log_debug(gc, stringdedup)(" Inspected: " G1_STRDEDUP_OBJECTS_FORMAT, stat._inspected); 132 log_debug(gc, stringdedup)(" Skipped: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", stat._skipped, skipped_percent); 133 log_debug(gc, stringdedup)(" Hashed: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", stat._hashed, hashed_percent); 134 log_debug(gc, stringdedup)(" Known: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", stat._known, known_percent); 135 log_debug(gc, stringdedup)(" New: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT, 136 stat._new, new_percent, G1_STRDEDUP_BYTES_PARAM(stat._new_bytes)); 137 log_debug(gc, stringdedup)(" Deduplicated: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", 138 stat._deduped, deduped_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_bytes), deduped_bytes_percent); 139 log_debug(gc, stringdedup)(" Young: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", 140 stat._deduped_young, deduped_young_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_young_bytes), deduped_young_bytes_percent); 141 log_debug(gc, stringdedup)(" Old: " G1_STRDEDUP_OBJECTS_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ") " G1_STRDEDUP_BYTES_FORMAT "(" G1_STRDEDUP_PERCENT_FORMAT ")", 142 stat._deduped_old, deduped_old_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_old_bytes), deduped_old_bytes_percent); 143 } | 1 /* 2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 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 #include "precompiled.hpp" 26 27 #include "gc/g1/g1CollectedHeap.inline.hpp" 28 #include "gc/g1/g1StringDedupStat.hpp" 29 #include "logging/log.hpp" 30 31 G1StringDedupStat::G1StringDedupStat() : StringDedupStat(), 32 _deduped_young(0), 33 _deduped_young_bytes(0), 34 _deduped_old(0), 35 _deduped_old_bytes(0), 36 _heap(G1CollectedHeap::heap()) { 37 } 38 39 40 41 void G1StringDedupStat::deduped(oop obj, uintx bytes) { 42 StringDedupStat::deduped(obj, bytes); 43 if (_heap->is_in_young(obj)) { 44 _deduped_young ++; 45 _deduped_young_bytes += bytes; 46 } else { 47 _deduped_old ++; 48 _deduped_old_bytes += bytes; 49 } 50 } 51 52 void G1StringDedupStat::add(const StringDedupStat* const stat) { 53 StringDedupStat::add(stat); 54 const G1StringDedupStat* const g1_stat = (const G1StringDedupStat* const)stat; 55 _deduped_young += g1_stat->_deduped_young; 56 _deduped_young_bytes += g1_stat->_deduped_young_bytes; 57 _deduped_old += g1_stat->_deduped_old; 58 _deduped_old_bytes += g1_stat->_deduped_old_bytes; 59 } 60 61 void G1StringDedupStat::print_statistics(bool total) const { 62 StringDedupStat::print_statistics(total); 63 64 double deduped_young_percent = percent_of(_deduped_young, _deduped); 65 double deduped_young_bytes_percent = percent_of(_deduped_young_bytes, _deduped_bytes); 66 double deduped_old_percent = percent_of(_deduped_old, _deduped); 67 double deduped_old_bytes_percent = percent_of(_deduped_old_bytes, _deduped_bytes); 68 69 log_debug(gc, stringdedup)(" Young: " STRDEDUP_OBJECTS_FORMAT "(" STRDEDUP_PERCENT_FORMAT ") " STRDEDUP_BYTES_FORMAT "(" STRDEDUP_PERCENT_FORMAT ")", 70 _deduped_young, deduped_young_percent, STRDEDUP_BYTES_PARAM(_deduped_young_bytes), deduped_young_bytes_percent); 71 log_debug(gc, stringdedup)(" Old: " STRDEDUP_OBJECTS_FORMAT "(" STRDEDUP_PERCENT_FORMAT ") " STRDEDUP_BYTES_FORMAT "(" STRDEDUP_PERCENT_FORMAT ")", 72 _deduped_old, deduped_old_percent, STRDEDUP_BYTES_PARAM(_deduped_old_bytes), deduped_old_bytes_percent); 73 74 } 75 76 void G1StringDedupStat::reset() { 77 StringDedupStat::reset(); 78 _deduped_young = 0; 79 _deduped_young_bytes = 0; 80 _deduped_old = 0; 81 _deduped_old_bytes = 0; 82 } |