g1StringDedupStat.cpp revision 8413:92457dfb91bd
11553Srgrimes/* 21553Srgrimes * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. 31553Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41553Srgrimes * 51553Srgrimes * This code is free software; you can redistribute it and/or modify it 61553Srgrimes * under the terms of the GNU General Public License version 2 only, as 71553Srgrimes * published by the Free Software Foundation. 81553Srgrimes * 91553Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT 101553Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 111553Srgrimes * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 121553Srgrimes * version 2 for more details (a copy is included in the LICENSE file that 131553Srgrimes * accompanied this code). 141553Srgrimes * 151553Srgrimes * You should have received a copy of the GNU General Public License version 161553Srgrimes * 2 along with this work; if not, write to the Free Software Foundation, 171553Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 181553Srgrimes * 191553Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 201553Srgrimes * or visit www.oracle.com if you need additional information or have any 211553Srgrimes * questions. 221553Srgrimes * 231553Srgrimes */ 241553Srgrimes 251553Srgrimes#include "precompiled.hpp" 261553Srgrimes#include "gc/g1/g1StringDedupStat.hpp" 271553Srgrimes 281553SrgrimesG1StringDedupStat::G1StringDedupStat() : 291553Srgrimes _inspected(0), 301553Srgrimes _skipped(0), 3130642Scharnier _hashed(0), 321553Srgrimes _known(0), 3330642Scharnier _new(0), 3430642Scharnier _new_bytes(0), 3550479Speter _deduped(0), 361553Srgrimes _deduped_bytes(0), 371553Srgrimes _deduped_young(0), 381553Srgrimes _deduped_young_bytes(0), 391553Srgrimes _deduped_old(0), 40202204Sed _deduped_old_bytes(0), 411553Srgrimes _idle(0), 421553Srgrimes _exec(0), 431553Srgrimes _block(0), 441553Srgrimes _start(0.0), 451553Srgrimes _idle_elapsed(0.0), 461553Srgrimes _exec_elapsed(0.0), 471553Srgrimes _block_elapsed(0.0) { 481553Srgrimes} 4930872Scharnier 501553Srgrimesvoid G1StringDedupStat::add(const G1StringDedupStat& stat) { 511553Srgrimes _inspected += stat._inspected; 521553Srgrimes _skipped += stat._skipped; 53173412Skevlo _hashed += stat._hashed; 54173412Skevlo _known += stat._known; 55173412Skevlo _new += stat._new; 561553Srgrimes _new_bytes += stat._new_bytes; 571553Srgrimes _deduped += stat._deduped; 58246209Scharnier _deduped_bytes += stat._deduped_bytes; 591553Srgrimes _deduped_young += stat._deduped_young; 601553Srgrimes _deduped_young_bytes += stat._deduped_young_bytes; 611553Srgrimes _deduped_old += stat._deduped_old; 621553Srgrimes _deduped_old_bytes += stat._deduped_old_bytes; 631553Srgrimes _idle += stat._idle; 641553Srgrimes _exec += stat._exec; 651553Srgrimes _block += stat._block; 661553Srgrimes _idle_elapsed += stat._idle_elapsed; 671553Srgrimes _exec_elapsed += stat._exec_elapsed; 681553Srgrimes _block_elapsed += stat._block_elapsed; 691553Srgrimes} 7086644Sjhb 7137267Sbdevoid G1StringDedupStat::print_summary(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) { 721553Srgrimes double total_deduped_bytes_percent = 0.0; 731553Srgrimes 741553Srgrimes if (total_stat._new_bytes > 0) { 751553Srgrimes // Avoid division by zero 761553Srgrimes total_deduped_bytes_percent = (double)total_stat._deduped_bytes / (double)total_stat._new_bytes * 100.0; 771553Srgrimes } 78202204Sed 791553Srgrimes st->date_stamp(PrintGCDateStamps); 801553Srgrimes st->stamp(PrintGCTimeStamps); 811553Srgrimes st->print_cr( 821553Srgrimes "[GC concurrent-string-deduplication, " 831553Srgrimes G1_STRDEDUP_BYTES_FORMAT_NS"->"G1_STRDEDUP_BYTES_FORMAT_NS"("G1_STRDEDUP_BYTES_FORMAT_NS"), avg " 841553Srgrimes G1_STRDEDUP_PERCENT_FORMAT_NS", "G1_STRDEDUP_TIME_FORMAT"]", 851553Srgrimes G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes), 86239991Sed G1_STRDEDUP_BYTES_PARAM(last_stat._new_bytes - last_stat._deduped_bytes), 871553Srgrimes G1_STRDEDUP_BYTES_PARAM(last_stat._deduped_bytes), 881553Srgrimes total_deduped_bytes_percent, 891553Srgrimes last_stat._exec_elapsed); 901553Srgrimes} 911553Srgrimes 921553Srgrimesvoid G1StringDedupStat::print_statistics(outputStream* st, const G1StringDedupStat& stat, bool total) { 931553Srgrimes double young_percent = 0.0; 941553Srgrimes double old_percent = 0.0; 951553Srgrimes double skipped_percent = 0.0; 961553Srgrimes double hashed_percent = 0.0; 971553Srgrimes double known_percent = 0.0; 981553Srgrimes double new_percent = 0.0; 991553Srgrimes double deduped_percent = 0.0; 1001553Srgrimes double deduped_bytes_percent = 0.0; 1011553Srgrimes double deduped_young_percent = 0.0; 1021553Srgrimes double deduped_young_bytes_percent = 0.0; 1031553Srgrimes double deduped_old_percent = 0.0; 1041553Srgrimes double deduped_old_bytes_percent = 0.0; 1051553Srgrimes 106239991Sed if (stat._inspected > 0) { 1071553Srgrimes // Avoid division by zero 1081553Srgrimes skipped_percent = (double)stat._skipped / (double)stat._inspected * 100.0; 1091553Srgrimes hashed_percent = (double)stat._hashed / (double)stat._inspected * 100.0; 1101553Srgrimes known_percent = (double)stat._known / (double)stat._inspected * 100.0; 1111553Srgrimes new_percent = (double)stat._new / (double)stat._inspected * 100.0; 1121553Srgrimes } 1131553Srgrimes 1141553Srgrimes if (stat._new > 0) { 1151553Srgrimes // Avoid division by zero 1161553Srgrimes deduped_percent = (double)stat._deduped / (double)stat._new * 100.0; 1171553Srgrimes } 1181553Srgrimes 1191553Srgrimes if (stat._deduped > 0) { 1201553Srgrimes // Avoid division by zero 1211553Srgrimes deduped_young_percent = (double)stat._deduped_young / (double)stat._deduped * 100.0; 1221553Srgrimes deduped_old_percent = (double)stat._deduped_old / (double)stat._deduped * 100.0; 1231553Srgrimes } 1241553Srgrimes 1251553Srgrimes if (stat._new_bytes > 0) { 1261553Srgrimes // Avoid division by zero 1271553Srgrimes deduped_bytes_percent = (double)stat._deduped_bytes / (double)stat._new_bytes * 100.0; 1281553Srgrimes } 1291553Srgrimes 1301553Srgrimes if (stat._deduped_bytes > 0) { 1311553Srgrimes // Avoid division by zero 1321553Srgrimes deduped_young_bytes_percent = (double)stat._deduped_young_bytes / (double)stat._deduped_bytes * 100.0; 1331553Srgrimes deduped_old_bytes_percent = (double)stat._deduped_old_bytes / (double)stat._deduped_bytes * 100.0; 1341553Srgrimes } 135239991Sed 1361553Srgrimes if (total) { 1371553Srgrimes st->print_cr( 1381553Srgrimes " [Total Exec: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT", Idle: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT", Blocked: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT"]", 1391553Srgrimes stat._exec, stat._exec_elapsed, stat._idle, stat._idle_elapsed, stat._block, stat._block_elapsed); 1401553Srgrimes } else { 1411553Srgrimes st->print_cr( 1421553Srgrimes " [Last Exec: "G1_STRDEDUP_TIME_FORMAT", Idle: "G1_STRDEDUP_TIME_FORMAT", Blocked: "UINTX_FORMAT"/"G1_STRDEDUP_TIME_FORMAT"]", 1431553Srgrimes stat._exec_elapsed, stat._idle_elapsed, stat._block, stat._block_elapsed); 1441553Srgrimes } 1451553Srgrimes st->print_cr( 1461553Srgrimes " [Inspected: "G1_STRDEDUP_OBJECTS_FORMAT"]\n" 14730830Scharnier " [Skipped: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1481553Srgrimes " [Hashed: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1491553Srgrimes " [Known: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1501553Srgrimes " [New: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"]\n" 1511553Srgrimes " [Deduplicated: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1521553Srgrimes " [Young: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]\n" 1531553Srgrimes " [Old: "G1_STRDEDUP_OBJECTS_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT") "G1_STRDEDUP_BYTES_FORMAT"("G1_STRDEDUP_PERCENT_FORMAT")]", 1541553Srgrimes stat._inspected, 1551553Srgrimes stat._skipped, skipped_percent, 156239991Sed stat._hashed, hashed_percent, 1571553Srgrimes stat._known, known_percent, 1581553Srgrimes stat._new, new_percent, G1_STRDEDUP_BYTES_PARAM(stat._new_bytes), 1591553Srgrimes stat._deduped, deduped_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_bytes), deduped_bytes_percent, 1601553Srgrimes stat._deduped_young, deduped_young_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_young_bytes), deduped_young_bytes_percent, 1611553Srgrimes stat._deduped_old, deduped_old_percent, G1_STRDEDUP_BYTES_PARAM(stat._deduped_old_bytes), deduped_old_bytes_percent); 1621553Srgrimes} 1631553Srgrimes