aoqi@0: /* aoqi@0: * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1STRINGDEDUPSTAT_HPP aoqi@0: #define SHARE_VM_GC_IMPLEMENTATION_G1_G1STRINGDEDUPSTAT_HPP aoqi@0: aoqi@0: #include "memory/allocation.hpp" aoqi@0: #include "runtime/os.hpp" aoqi@0: aoqi@0: // Macros for GC log output formating aoqi@0: #define G1_STRDEDUP_OBJECTS_FORMAT UINTX_FORMAT_W(12) aoqi@0: #define G1_STRDEDUP_TIME_FORMAT "%1.7lf secs" aoqi@0: #define G1_STRDEDUP_PERCENT_FORMAT "%5.1lf%%" aoqi@0: #define G1_STRDEDUP_PERCENT_FORMAT_NS "%.1lf%%" aoqi@0: #define G1_STRDEDUP_BYTES_FORMAT "%8.1lf%s" aoqi@0: #define G1_STRDEDUP_BYTES_FORMAT_NS "%.1lf%s" aoqi@0: #define G1_STRDEDUP_BYTES_PARAM(bytes) byte_size_in_proper_unit((double)(bytes)), proper_unit_for_byte_size((bytes)) aoqi@0: aoqi@0: // aoqi@0: // Statistics gathered by the deduplication thread. aoqi@0: // aoqi@0: class G1StringDedupStat : public StackObj { aoqi@0: private: aoqi@0: // Counters aoqi@0: uintx _inspected; aoqi@0: uintx _skipped; aoqi@0: uintx _hashed; aoqi@0: uintx _known; aoqi@0: uintx _new; aoqi@0: uintx _new_bytes; aoqi@0: uintx _deduped; aoqi@0: uintx _deduped_bytes; aoqi@0: uintx _deduped_young; aoqi@0: uintx _deduped_young_bytes; aoqi@0: uintx _deduped_old; aoqi@0: uintx _deduped_old_bytes; aoqi@0: uintx _idle; aoqi@0: uintx _exec; aoqi@0: uintx _block; aoqi@0: aoqi@0: // Time spent by the deduplication thread in different phases aoqi@0: double _start; aoqi@0: double _idle_elapsed; aoqi@0: double _exec_elapsed; aoqi@0: double _block_elapsed; aoqi@0: aoqi@0: public: aoqi@0: G1StringDedupStat(); aoqi@0: aoqi@0: void inc_inspected() { aoqi@0: _inspected++; aoqi@0: } aoqi@0: aoqi@0: void inc_skipped() { aoqi@0: _skipped++; aoqi@0: } aoqi@0: aoqi@0: void inc_hashed() { aoqi@0: _hashed++; aoqi@0: } aoqi@0: aoqi@0: void inc_known() { aoqi@0: _known++; aoqi@0: } aoqi@0: aoqi@0: void inc_new(uintx bytes) { aoqi@0: _new++; aoqi@0: _new_bytes += bytes; aoqi@0: } aoqi@0: aoqi@0: void inc_deduped_young(uintx bytes) { aoqi@0: _deduped++; aoqi@0: _deduped_bytes += bytes; aoqi@0: _deduped_young++; aoqi@0: _deduped_young_bytes += bytes; aoqi@0: } aoqi@0: aoqi@0: void inc_deduped_old(uintx bytes) { aoqi@0: _deduped++; aoqi@0: _deduped_bytes += bytes; aoqi@0: _deduped_old++; aoqi@0: _deduped_old_bytes += bytes; aoqi@0: } aoqi@0: aoqi@0: void mark_idle() { aoqi@0: _start = os::elapsedTime(); aoqi@0: _idle++; aoqi@0: } aoqi@0: aoqi@0: void mark_exec() { aoqi@0: double now = os::elapsedTime(); aoqi@0: _idle_elapsed = now - _start; aoqi@0: _start = now; aoqi@0: _exec++; aoqi@0: } aoqi@0: aoqi@0: void mark_block() { aoqi@0: double now = os::elapsedTime(); aoqi@0: _exec_elapsed += now - _start; aoqi@0: _start = now; aoqi@0: _block++; aoqi@0: } aoqi@0: aoqi@0: void mark_unblock() { aoqi@0: double now = os::elapsedTime(); aoqi@0: _block_elapsed += now - _start; aoqi@0: _start = now; aoqi@0: } aoqi@0: aoqi@0: void mark_done() { aoqi@0: double now = os::elapsedTime(); aoqi@0: _exec_elapsed += now - _start; aoqi@0: } aoqi@0: aoqi@0: void add(const G1StringDedupStat& stat); aoqi@0: aoqi@0: static void print_summary(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat); aoqi@0: static void print_statistics(outputStream* st, const G1StringDedupStat& stat, bool total); aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1STRINGDEDUPSTAT_HPP