Path: blob/master/src/hotspot/share/gc/g1/g1Analytics.hpp
40957 views
/*1* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_GC_G1_G1ANALYTICS_HPP25#define SHARE_GC_G1_G1ANALYTICS_HPP2627#include "memory/allocation.hpp"28#include "utilities/globalDefinitions.hpp"2930class TruncatedSeq;31class G1Predictions;3233class G1Analytics: public CHeapObj<mtGC> {34const static int TruncatedSeqLength = 10;35const static int NumPrevPausesForHeuristics = 10;36const G1Predictions* _predictor;3738// These exclude marking times.39TruncatedSeq* _recent_gc_times_ms;4041TruncatedSeq* _concurrent_mark_remark_times_ms;42TruncatedSeq* _concurrent_mark_cleanup_times_ms;4344TruncatedSeq* _alloc_rate_ms_seq;45double _prev_collection_pause_end_ms;4647TruncatedSeq* _rs_length_diff_seq;48TruncatedSeq* _concurrent_refine_rate_ms_seq;49TruncatedSeq* _dirtied_cards_rate_ms_seq;50// The ratio between the number of merged cards and actually scanned cards, for51// young-only and mixed gcs.52TruncatedSeq* _young_card_merge_to_scan_ratio_seq;53TruncatedSeq* _mixed_card_merge_to_scan_ratio_seq;5455// The cost to scan a card during young-only and mixed gcs in ms.56TruncatedSeq* _young_cost_per_card_scan_ms_seq;57TruncatedSeq* _mixed_cost_per_card_scan_ms_seq;5859// The cost to merge a card during young-only and mixed gcs in ms.60TruncatedSeq* _young_cost_per_card_merge_ms_seq;61TruncatedSeq* _mixed_cost_per_card_merge_ms_seq;6263// The cost to copy a byte in ms.64TruncatedSeq* _copy_cost_per_byte_ms_seq;65TruncatedSeq* _constant_other_time_ms_seq;66TruncatedSeq* _young_other_cost_per_region_ms_seq;67TruncatedSeq* _non_young_other_cost_per_region_ms_seq;6869TruncatedSeq* _pending_cards_seq;70TruncatedSeq* _rs_length_seq;7172TruncatedSeq* _cost_per_byte_ms_during_cm_seq;7374// Statistics kept per GC stoppage, pause or full.75TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;7677// Cached values for long and short term pause time ratios. See78// compute_pause_time_ratios() for how they are computed.79double _long_term_pause_time_ratio;80double _short_term_pause_time_ratio;8182// Returns whether the sequence have enough samples to get a "good" prediction.83// The constant used is random but "small".84bool enough_samples_available(TruncatedSeq const* seq) const;8586double predict_in_unit_interval(TruncatedSeq const* seq) const;87size_t predict_size(TruncatedSeq const* seq) const;88double predict_zero_bounded(TruncatedSeq const* seq) const;8990double oldest_known_gc_end_time_sec() const;91double most_recent_gc_end_time_sec() const;9293public:94G1Analytics(const G1Predictions* predictor);9596double prev_collection_pause_end_ms() const {97return _prev_collection_pause_end_ms;98}99100double long_term_pause_time_ratio() const {101return _long_term_pause_time_ratio;102}103104double short_term_pause_time_ratio() const {105return _short_term_pause_time_ratio;106}107108uint number_of_recorded_pause_times() const {109return NumPrevPausesForHeuristics;110}111112void append_prev_collection_pause_end_ms(double ms) {113_prev_collection_pause_end_ms += ms;114}115116void set_prev_collection_pause_end_ms(double ms) {117_prev_collection_pause_end_ms = ms;118}119120void report_concurrent_mark_remark_times_ms(double ms);121void report_concurrent_mark_cleanup_times_ms(double ms);122void report_alloc_rate_ms(double alloc_rate);123void report_concurrent_refine_rate_ms(double cards_per_ms);124void report_dirtied_cards_rate_ms(double cards_per_ms);125void report_cost_per_card_scan_ms(double cost_per_remset_card_ms, bool for_young_gc);126void report_cost_per_card_merge_ms(double cost_per_card_ms, bool for_young_gc);127void report_card_merge_to_scan_ratio(double cards_per_entry_ratio, bool for_young_gc);128void report_rs_length_diff(double rs_length_diff);129void report_cost_per_byte_ms(double cost_per_byte_ms, bool mark_or_rebuild_in_progress);130void report_young_other_cost_per_region_ms(double other_cost_per_region_ms);131void report_non_young_other_cost_per_region_ms(double other_cost_per_region_ms);132void report_constant_other_time_ms(double constant_other_time_ms);133void report_pending_cards(double pending_cards);134void report_rs_length(double rs_length);135136double predict_alloc_rate_ms() const;137int num_alloc_rate_ms() const;138139double predict_concurrent_refine_rate_ms() const;140double predict_dirtied_cards_rate_ms() const;141double predict_young_card_merge_to_scan_ratio() const;142143double predict_mixed_card_merge_to_scan_ratio() const;144145size_t predict_scan_card_num(size_t rs_length, bool for_young_gc) const;146147double predict_card_merge_time_ms(size_t card_num, bool for_young_gc) const;148double predict_card_scan_time_ms(size_t card_num, bool for_young_gc) const;149150double predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) const;151152double predict_object_copy_time_ms(size_t bytes_to_copy, bool during_concurrent_mark) const;153154double predict_constant_other_time_ms() const;155156double predict_young_other_time_ms(size_t young_num) const;157158double predict_non_young_other_time_ms(size_t non_young_num) const;159160double predict_remark_time_ms() const;161162double predict_cleanup_time_ms() const;163164size_t predict_rs_length() const;165size_t predict_pending_cards() const;166167// Add a new GC of the given duration and end time to the record.168void update_recent_gc_times(double end_time_sec, double elapsed_ms);169void compute_pause_time_ratios(double end_time_sec, double pause_time_ms);170};171172#endif // SHARE_GC_G1_G1ANALYTICS_HPP173174175