1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/g1StringDedupStat.cpp Tue Mar 18 19:07:22 2014 +0100 1.3 @@ -0,0 +1,162 @@ 1.4 +/* 1.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "gc_implementation/g1/g1StringDedupStat.hpp" 1.30 + 1.31 +G1StringDedupStat::G1StringDedupStat() : 1.32 + _inspected(0), 1.33 + _skipped(0), 1.34 + _hashed(0), 1.35 + _known(0), 1.36 + _new(0), 1.37 + _new_bytes(0), 1.38 + _deduped(0), 1.39 + _deduped_bytes(0), 1.40 + _deduped_young(0), 1.41 + _deduped_young_bytes(0), 1.42 + _deduped_old(0), 1.43 + _deduped_old_bytes(0), 1.44 + _idle(0), 1.45 + _exec(0), 1.46 + _block(0), 1.47 + _start(0.0), 1.48 + _idle_elapsed(0.0), 1.49 + _exec_elapsed(0.0), 1.50 + _block_elapsed(0.0) { 1.51 +} 1.52 + 1.53 +void G1StringDedupStat::add(const G1StringDedupStat& stat) { 1.54 + _inspected += stat._inspected; 1.55 + _skipped += stat._skipped; 1.56 + _hashed += stat._hashed; 1.57 + _known += stat._known; 1.58 + _new += stat._new; 1.59 + _new_bytes += stat._new_bytes; 1.60 + _deduped += stat._deduped; 1.61 + _deduped_bytes += stat._deduped_bytes; 1.62 + _deduped_young += stat._deduped_young; 1.63 + _deduped_young_bytes += stat._deduped_young_bytes; 1.64 + _deduped_old += stat._deduped_old; 1.65 + _deduped_old_bytes += stat._deduped_old_bytes; 1.66 + _idle += stat._idle; 1.67 + _exec += stat._exec; 1.68 + _block += stat._block; 1.69 + _idle_elapsed += stat._idle_elapsed; 1.70 + _exec_elapsed += stat._exec_elapsed; 1.71 + _block_elapsed += stat._block_elapsed; 1.72 +} 1.73 + 1.74 +void G1StringDedupStat::print_summary(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) { 1.75 + double total_deduped_bytes_percent = 0.0; 1.76 + 1.77 + if (total_stat._new_bytes > 0) { 1.78 + // Avoid division by zero 1.79 + total_deduped_bytes_percent = (double)total_stat._deduped_bytes / (double)total_stat._new_bytes * 100.0; 1.80 + } 1.81 + 1.82 + st->date_stamp(PrintGCDateStamps); 1.83 + st->stamp(PrintGCTimeStamps); 1.84 + st->print_cr( 1.85 + "[GC concurrent-string-deduplication, " 1.86 + G1_STRDEDUP_BYTES_FORMAT_NS"->"G1_STRDEDUP_BYTES_FORMAT_NS"("G1_STRDEDUP_BYTES_FORMAT_NS"), avg " 1.87 + G1_STRDEDUP_PERCENT_FORMAT_NS", "G1_STRDEDUP_TIME_FORMAT"]", 1.88 + G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes), 1.89 + G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes - last_stat._deduped_bytes), 1.90 + G1_STRDEDUP_BYTES_PARAM(last_stat._deduped_bytes), 1.91 + total_deduped_bytes_percent, 1.92 + last_stat._exec_elapsed); 1.93 +} 1.94 + 1.95 +void G1StringDedupStat::print_statistics(outputStream* st, const G1StringDedupStat& stat, bool total) { 1.96 + double young_percent = 0.0; 1.97 + double old_percent = 0.0; 1.98 + double skipped_percent = 0.0; 1.99 + double hashed_percent = 0.0; 1.100 + double known_percent = 0.0; 1.101 + double new_percent = 0.0; 1.102 + double deduped_percent = 0.0; 1.103 + double deduped_bytes_percent = 0.0; 1.104 + double deduped_young_percent = 0.0; 1.105 + double deduped_young_bytes_percent = 0.0; 1.106 + double deduped_old_percent = 0.0; 1.107 + double deduped_old_bytes_percent = 0.0; 1.108 + 1.109 + if (stat._inspected > 0) { 1.110 + // Avoid division by zero 1.111 + skipped_percent = (double)stat._skipped / (double)stat._inspected * 100.0; 1.112 + hashed_percent = (double)stat._hashed / (double)stat._inspected * 100.0; 1.113 + known_percent = (double)stat._known / (double)stat._inspected * 100.0; 1.114 + new_percent = (double)stat._new / (double)stat._inspected * 100.0; 1.115 + } 1.116 + 1.117 + if (stat._new > 0) { 1.118 + // Avoid division by zero 1.119 + deduped_percent = (double)stat._deduped / (double)stat._new * 100.0; 1.120 + } 1.121 + 1.122 + if (stat._deduped > 0) { 1.123 + // Avoid division by zero 1.124 + deduped_young_percent = (double)stat._deduped_young / (double)stat._deduped * 100.0; 1.125 + deduped_old_percent = (double)stat._deduped_old / (double)stat._deduped * 100.0; 1.126 + } 1.127 + 1.128 + if (stat._new_bytes > 0) { 1.129 + // Avoid division by zero 1.130 + deduped_bytes_percent = (double)stat._deduped_bytes / (double)stat._new_bytes * 100.0; 1.131 + } 1.132 + 1.133 + if (stat._deduped_bytes > 0) { 1.134 + // Avoid division by zero 1.135 + deduped_young_bytes_percent = (double)stat._deduped_young_bytes / (double)stat._deduped_bytes * 100.0; 1.136 + deduped_old_bytes_percent = (double)stat._deduped_old_bytes / (double)stat._deduped_bytes * 100.0; 1.137 + } 1.138 + 1.139 + if (total) { 1.140 + st->print_cr( 1.141 + " [Total Exec: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT", Idle: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT", Blocked: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT"]", 1.142 + stat._exec, stat._exec_elapsed, stat._idle, stat._idle_elapsed, stat._block, stat._block_elapsed); 1.143 + } else { 1.144 + st->print_cr( 1.145 + " [Last Exec: "G1_STRDEDUP_TIME_FORMAT", Idle: "G1_STRDEDUP_TIME_FORMAT", Blocked: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT"]", 1.146 + stat._exec_elapsed, stat._idle_elapsed, stat._block, stat._block_elapsed); 1.147 + } 1.148 + st->print_cr( 1.149 + " [Inspected: "G1_STRDEDUP_OBJECTS_FORMAT"]\n" 1.150 + " [Skipped: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1.151 + " [Hashed: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1.152 + " [Known: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1.153 + " [New: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"]\n" 1.154 + " [Deduplicated: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1.155 + " [Young: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1.156 + " [Old: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]", 1.157 + stat._inspected, 1.158 + stat._skipped, skipped_percent, 1.159 + stat._hashed, hashed_percent, 1.160 + stat._known, known_percent, 1.161 + stat._new, new_percent, G1_STRDEDUP_BYTES_PARAM(stat._new_bytes), 1.162 + stat._deduped, deduped_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_bytes), deduped_bytes_percent, 1.163 + stat._deduped_young, deduped_young_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_young_bytes), deduped_young_bytes_percent, 1.164 + stat._deduped_old, deduped_old_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_old_bytes), deduped_old_bytes_percent); 1.165 +}