g1CollectorPolicy.hpp revision 545
342N/A/*
342N/A * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved.
342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342N/A *
342N/A * This code is free software; you can redistribute it and/or modify it
342N/A * under the terms of the GNU General Public License version 2 only, as
342N/A * published by the Free Software Foundation.
342N/A *
342N/A * This code is distributed in the hope that it will be useful, but WITHOUT
342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
342N/A * version 2 for more details (a copy is included in the LICENSE file that
342N/A * accompanied this code).
342N/A *
342N/A * You should have received a copy of the GNU General Public License version
342N/A * 2 along with this work; if not, write to the Free Software Foundation,
342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342N/A *
342N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
342N/A * CA 95054 USA or visit www.sun.com if you need additional information or
342N/A * have any questions.
342N/A *
342N/A */
342N/A
342N/A// A G1CollectorPolicy makes policy decisions that determine the
342N/A// characteristics of the collector. Examples include:
342N/A// * choice of collection set.
342N/A// * when to collect.
342N/A
342N/Aclass HeapRegion;
342N/Aclass CollectionSetChooser;
342N/A
342N/A// Yes, this is a bit unpleasant... but it saves replicating the same thing
342N/A// over and over again and introducing subtle problems through small typos and
342N/A// cutting and pasting mistakes. The macros below introduces a number
342N/A// sequnce into the following two classes and the methods that access it.
342N/A
342N/A#define define_num_seq(name) \
342N/Aprivate: \
342N/A NumberSeq _all_##name##_times_ms; \
342N/Apublic: \
342N/A void record_##name##_time_ms(double ms) { \
342N/A _all_##name##_times_ms.add(ms); \
342N/A } \
342N/A NumberSeq* get_##name##_seq() { \
342N/A return &_all_##name##_times_ms; \
342N/A }
342N/A
342N/Aclass MainBodySummary;
342N/Aclass PopPreambleSummary;
342N/A
342N/Aclass PauseSummary {
342N/A define_num_seq(total)
342N/A define_num_seq(other)
342N/A
342N/Apublic:
342N/A virtual MainBodySummary* main_body_summary() { return NULL; }
342N/A virtual PopPreambleSummary* pop_preamble_summary() { return NULL; }
342N/A};
342N/A
342N/Aclass MainBodySummary {
342N/A define_num_seq(satb_drain) // optional
342N/A define_num_seq(parallel) // parallel only
342N/A define_num_seq(ext_root_scan)
342N/A define_num_seq(mark_stack_scan)
342N/A define_num_seq(scan_only)
342N/A define_num_seq(update_rs)
342N/A define_num_seq(scan_rs)
342N/A define_num_seq(scan_new_refs) // Only for temp use; added to
342N/A // in parallel case.
342N/A define_num_seq(obj_copy)
342N/A define_num_seq(termination) // parallel only
342N/A define_num_seq(parallel_other) // parallel only
342N/A define_num_seq(mark_closure)
342N/A define_num_seq(clear_ct) // parallel only
342N/A};
342N/A
342N/Aclass PopPreambleSummary {
342N/A define_num_seq(pop_preamble)
342N/A define_num_seq(pop_update_rs)
342N/A define_num_seq(pop_scan_rs)
342N/A define_num_seq(pop_closure_app)
342N/A define_num_seq(pop_evacuation)
342N/A define_num_seq(pop_other)
342N/A};
342N/A
342N/Aclass NonPopSummary: public PauseSummary,
342N/A public MainBodySummary {
342N/Apublic:
342N/A virtual MainBodySummary* main_body_summary() { return this; }
342N/A};
342N/A
342N/Aclass PopSummary: public PauseSummary,
342N/A public MainBodySummary,
342N/A public PopPreambleSummary {
342N/Apublic:
342N/A virtual MainBodySummary* main_body_summary() { return this; }
342N/A virtual PopPreambleSummary* pop_preamble_summary() { return this; }
342N/A};
342N/A
342N/Aclass NonPopAbandonedSummary: public PauseSummary {
342N/A};
342N/A
342N/Aclass PopAbandonedSummary: public PauseSummary,
342N/A public PopPreambleSummary {
342N/Apublic:
342N/A virtual PopPreambleSummary* pop_preamble_summary() { return this; }
342N/A};
342N/A
342N/Aclass G1CollectorPolicy: public CollectorPolicy {
342N/Aprotected:
342N/A // The number of pauses during the execution.
342N/A long _n_pauses;
342N/A
342N/A // either equal to the number of parallel threads, if ParallelGCThreads
342N/A // has been set, or 1 otherwise
342N/A int _parallel_gc_threads;
342N/A
342N/A enum SomePrivateConstants {
342N/A NumPrevPausesForHeuristics = 10,
342N/A NumPrevGCsForHeuristics = 10,
342N/A NumAPIs = HeapRegion::MaxAge
342N/A };
342N/A
342N/A G1MMUTracker* _mmu_tracker;
342N/A
342N/A void initialize_flags();
342N/A
342N/A void initialize_all() {
342N/A initialize_flags();
342N/A initialize_size_info();
342N/A initialize_perm_generation(PermGen::MarkSweepCompact);
342N/A }
342N/A
342N/A virtual size_t default_init_heap_size() {
342N/A // Pick some reasonable default.
342N/A return 8*M;
342N/A }
342N/A
342N/A
342N/A double _cur_collection_start_sec;
342N/A size_t _cur_collection_pause_used_at_start_bytes;
342N/A size_t _cur_collection_pause_used_regions_at_start;
342N/A size_t _prev_collection_pause_used_at_end_bytes;
342N/A double _cur_collection_par_time_ms;
342N/A double _cur_satb_drain_time_ms;
342N/A double _cur_clear_ct_time_ms;
342N/A bool _satb_drain_time_set;
342N/A double _cur_popular_preamble_start_ms;
342N/A double _cur_popular_preamble_time_ms;
342N/A double _cur_popular_compute_rc_time_ms;
342N/A double _cur_popular_evac_time_ms;
342N/A
342N/A double _cur_CH_strong_roots_end_sec;
342N/A double _cur_CH_strong_roots_dur_ms;
342N/A double _cur_G1_strong_roots_end_sec;
342N/A double _cur_G1_strong_roots_dur_ms;
342N/A
342N/A // Statistics for recent GC pauses. See below for how indexed.
342N/A TruncatedSeq* _recent_CH_strong_roots_times_ms;
342N/A TruncatedSeq* _recent_G1_strong_roots_times_ms;
342N/A TruncatedSeq* _recent_evac_times_ms;
342N/A // These exclude marking times.
342N/A TruncatedSeq* _recent_pause_times_ms;
342N/A TruncatedSeq* _recent_gc_times_ms;
342N/A
342N/A TruncatedSeq* _recent_CS_bytes_used_before;
342N/A TruncatedSeq* _recent_CS_bytes_surviving;
342N/A
342N/A TruncatedSeq* _recent_rs_sizes;
342N/A
342N/A TruncatedSeq* _concurrent_mark_init_times_ms;
342N/A TruncatedSeq* _concurrent_mark_remark_times_ms;
342N/A TruncatedSeq* _concurrent_mark_cleanup_times_ms;
342N/A
342N/A NonPopSummary* _non_pop_summary;
342N/A PopSummary* _pop_summary;
342N/A NonPopAbandonedSummary* _non_pop_abandoned_summary;
342N/A PopAbandonedSummary* _pop_abandoned_summary;
342N/A
342N/A NumberSeq* _all_pause_times_ms;
342N/A NumberSeq* _all_full_gc_times_ms;
342N/A double _stop_world_start;
342N/A NumberSeq* _all_stop_world_times_ms;
342N/A NumberSeq* _all_yield_times_ms;
342N/A
342N/A size_t _region_num_young;
342N/A size_t _region_num_tenured;
342N/A size_t _prev_region_num_young;
342N/A size_t _prev_region_num_tenured;
342N/A
342N/A NumberSeq* _all_mod_union_times_ms;
342N/A
342N/A int _aux_num;
342N/A NumberSeq* _all_aux_times_ms;
342N/A double* _cur_aux_start_times_ms;
342N/A double* _cur_aux_times_ms;
342N/A bool* _cur_aux_times_set;
342N/A
342N/A double* _par_last_ext_root_scan_times_ms;
342N/A double* _par_last_mark_stack_scan_times_ms;
342N/A double* _par_last_scan_only_times_ms;
342N/A double* _par_last_scan_only_regions_scanned;
342N/A double* _par_last_update_rs_start_times_ms;
342N/A double* _par_last_update_rs_times_ms;
342N/A double* _par_last_update_rs_processed_buffers;
342N/A double* _par_last_scan_rs_start_times_ms;
342N/A double* _par_last_scan_rs_times_ms;
342N/A double* _par_last_scan_new_refs_times_ms;
342N/A double* _par_last_obj_copy_times_ms;
342N/A double* _par_last_termination_times_ms;
342N/A
342N/A // there are two pases during popular pauses, so we need to store
342N/A // somewhere the results of the first pass
342N/A double* _pop_par_last_update_rs_start_times_ms;
342N/A double* _pop_par_last_update_rs_times_ms;
342N/A double* _pop_par_last_update_rs_processed_buffers;
342N/A double* _pop_par_last_scan_rs_start_times_ms;
342N/A double* _pop_par_last_scan_rs_times_ms;
342N/A double* _pop_par_last_closure_app_times_ms;
342N/A
342N/A double _pop_compute_rc_start;
342N/A double _pop_evac_start;
342N/A
342N/A // indicates that we are in young GC mode
342N/A bool _in_young_gc_mode;
342N/A
342N/A // indicates whether we are in full young or partially young GC mode
342N/A bool _full_young_gcs;
342N/A
342N/A // if true, then it tries to dynamically adjust the length of the
342N/A // young list
342N/A bool _adaptive_young_list_length;
342N/A size_t _young_list_min_length;
342N/A size_t _young_list_target_length;
342N/A size_t _young_list_so_prefix_length;
342N/A size_t _young_list_fixed_length;
342N/A
342N/A size_t _young_cset_length;
342N/A bool _last_young_gc_full;
342N/A
342N/A double _target_pause_time_ms;
342N/A
342N/A unsigned _full_young_pause_num;
342N/A unsigned _partial_young_pause_num;
342N/A
342N/A bool _during_marking;
342N/A bool _in_marking_window;
342N/A bool _in_marking_window_im;
342N/A
342N/A SurvRateGroup* _short_lived_surv_rate_group;
342N/A SurvRateGroup* _survivor_surv_rate_group;
342N/A // add here any more surv rate groups
342N/A
342N/A bool during_marking() {
342N/A return _during_marking;
342N/A }
342N/A
342N/A // <NEW PREDICTION>
342N/A
342N/Aprivate:
342N/A enum PredictionConstants {
342N/A TruncatedSeqLength = 10
342N/A };
342N/A
342N/A TruncatedSeq* _alloc_rate_ms_seq;
342N/A double _prev_collection_pause_end_ms;
342N/A
342N/A TruncatedSeq* _pending_card_diff_seq;
342N/A TruncatedSeq* _rs_length_diff_seq;
342N/A TruncatedSeq* _cost_per_card_ms_seq;
342N/A TruncatedSeq* _cost_per_scan_only_region_ms_seq;
342N/A TruncatedSeq* _fully_young_cards_per_entry_ratio_seq;
342N/A TruncatedSeq* _partially_young_cards_per_entry_ratio_seq;
342N/A TruncatedSeq* _cost_per_entry_ms_seq;
342N/A TruncatedSeq* _partially_young_cost_per_entry_ms_seq;
342N/A TruncatedSeq* _cost_per_byte_ms_seq;
342N/A TruncatedSeq* _constant_other_time_ms_seq;
342N/A TruncatedSeq* _young_other_cost_per_region_ms_seq;
342N/A TruncatedSeq* _non_young_other_cost_per_region_ms_seq;
342N/A
342N/A TruncatedSeq* _pending_cards_seq;
342N/A TruncatedSeq* _scanned_cards_seq;
342N/A TruncatedSeq* _rs_lengths_seq;
342N/A
342N/A TruncatedSeq* _cost_per_byte_ms_during_cm_seq;
342N/A TruncatedSeq* _cost_per_scan_only_region_ms_during_cm_seq;
342N/A
342N/A TruncatedSeq* _young_gc_eff_seq;
342N/A
342N/A TruncatedSeq* _max_conc_overhead_seq;
342N/A
342N/A size_t _recorded_young_regions;
342N/A size_t _recorded_scan_only_regions;
342N/A size_t _recorded_non_young_regions;
342N/A size_t _recorded_region_num;
342N/A
342N/A size_t _free_regions_at_end_of_collection;
342N/A size_t _scan_only_regions_at_end_of_collection;
342N/A
342N/A size_t _recorded_rs_lengths;
342N/A size_t _max_rs_lengths;
342N/A
342N/A size_t _recorded_marked_bytes;
342N/A size_t _recorded_young_bytes;
342N/A
342N/A size_t _predicted_pending_cards;
342N/A size_t _predicted_cards_scanned;
342N/A size_t _predicted_rs_lengths;
342N/A size_t _predicted_bytes_to_copy;
342N/A
342N/A double _predicted_survival_ratio;
342N/A double _predicted_rs_update_time_ms;
342N/A double _predicted_rs_scan_time_ms;
342N/A double _predicted_scan_only_scan_time_ms;
342N/A double _predicted_object_copy_time_ms;
342N/A double _predicted_constant_other_time_ms;
342N/A double _predicted_young_other_time_ms;
342N/A double _predicted_non_young_other_time_ms;
342N/A double _predicted_pause_time_ms;
342N/A
342N/A double _vtime_diff_ms;
342N/A
342N/A double _recorded_young_free_cset_time_ms;
342N/A double _recorded_non_young_free_cset_time_ms;
342N/A
342N/A double _sigma;
342N/A double _expensive_region_limit_ms;
342N/A
342N/A size_t _rs_lengths_prediction;
342N/A
342N/A size_t _known_garbage_bytes;
342N/A double _known_garbage_ratio;
342N/A
342N/A double sigma() {
342N/A return _sigma;
342N/A }
342N/A
342N/A // A function that prevents us putting too much stock in small sample
342N/A // sets. Returns a number between 2.0 and 1.0, depending on the number
342N/A // of samples. 5 or more samples yields one; fewer scales linearly from
342N/A // 2.0 at 1 sample to 1.0 at 5.
342N/A double confidence_factor(int samples) {
342N/A if (samples > 4) return 1.0;
342N/A else return 1.0 + sigma() * ((double)(5 - samples))/2.0;
342N/A }
342N/A
342N/A double get_new_neg_prediction(TruncatedSeq* seq) {
342N/A return seq->davg() - sigma() * seq->dsd();
342N/A }
342N/A
342N/A#ifndef PRODUCT
342N/A bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group);
342N/A#endif // PRODUCT
342N/A
342N/Aprotected:
342N/A double _pause_time_target_ms;
342N/A double _recorded_young_cset_choice_time_ms;
342N/A double _recorded_non_young_cset_choice_time_ms;
342N/A bool _within_target;
342N/A size_t _pending_cards;
342N/A size_t _max_pending_cards;
342N/A
342N/Apublic:
342N/A
342N/A void set_region_short_lived(HeapRegion* hr) {
342N/A hr->install_surv_rate_group(_short_lived_surv_rate_group);
342N/A }
342N/A
342N/A void set_region_survivors(HeapRegion* hr) {
342N/A hr->install_surv_rate_group(_survivor_surv_rate_group);
342N/A }
342N/A
342N/A#ifndef PRODUCT
342N/A bool verify_young_ages();
342N/A#endif // PRODUCT
342N/A
342N/A void tag_scan_only(size_t short_lived_scan_only_length);
342N/A
342N/A double get_new_prediction(TruncatedSeq* seq) {
342N/A return MAX2(seq->davg() + sigma() * seq->dsd(),
342N/A seq->davg() * confidence_factor(seq->num()));
342N/A }
342N/A
342N/A size_t young_cset_length() {
342N/A return _young_cset_length;
342N/A }
342N/A
342N/A void record_max_rs_lengths(size_t rs_lengths) {
342N/A _max_rs_lengths = rs_lengths;
342N/A }
342N/A
342N/A size_t predict_pending_card_diff() {
342N/A double prediction = get_new_neg_prediction(_pending_card_diff_seq);
342N/A if (prediction < 0.00001)
342N/A return 0;
342N/A else
342N/A return (size_t) prediction;
342N/A }
342N/A
342N/A size_t predict_pending_cards() {
342N/A size_t max_pending_card_num = _g1->max_pending_card_num();
342N/A size_t diff = predict_pending_card_diff();
342N/A size_t prediction;
342N/A if (diff > max_pending_card_num)
342N/A prediction = max_pending_card_num;
342N/A else
342N/A prediction = max_pending_card_num - diff;
342N/A
342N/A return prediction;
342N/A }
342N/A
342N/A size_t predict_rs_length_diff() {
342N/A return (size_t) get_new_prediction(_rs_length_diff_seq);
342N/A }
342N/A
342N/A double predict_alloc_rate_ms() {
342N/A return get_new_prediction(_alloc_rate_ms_seq);
342N/A }
342N/A
342N/A double predict_cost_per_card_ms() {
342N/A return get_new_prediction(_cost_per_card_ms_seq);
342N/A }
342N/A
342N/A double predict_rs_update_time_ms(size_t pending_cards) {
342N/A return (double) pending_cards * predict_cost_per_card_ms();
342N/A }
342N/A
342N/A double predict_fully_young_cards_per_entry_ratio() {
342N/A return get_new_prediction(_fully_young_cards_per_entry_ratio_seq);
342N/A }
342N/A
342N/A double predict_partially_young_cards_per_entry_ratio() {
342N/A if (_partially_young_cards_per_entry_ratio_seq->num() < 2)
342N/A return predict_fully_young_cards_per_entry_ratio();
342N/A else
342N/A return get_new_prediction(_partially_young_cards_per_entry_ratio_seq);
342N/A }
342N/A
342N/A size_t predict_young_card_num(size_t rs_length) {
342N/A return (size_t) ((double) rs_length *
342N/A predict_fully_young_cards_per_entry_ratio());
342N/A }
342N/A
342N/A size_t predict_non_young_card_num(size_t rs_length) {
342N/A return (size_t) ((double) rs_length *
342N/A predict_partially_young_cards_per_entry_ratio());
342N/A }
342N/A
342N/A double predict_rs_scan_time_ms(size_t card_num) {
342N/A if (full_young_gcs())
342N/A return (double) card_num * get_new_prediction(_cost_per_entry_ms_seq);
342N/A else
342N/A return predict_partially_young_rs_scan_time_ms(card_num);
342N/A }
342N/A
342N/A double predict_partially_young_rs_scan_time_ms(size_t card_num) {
342N/A if (_partially_young_cost_per_entry_ms_seq->num() < 3)
342N/A return (double) card_num * get_new_prediction(_cost_per_entry_ms_seq);
342N/A else
342N/A return (double) card_num *
342N/A get_new_prediction(_partially_young_cost_per_entry_ms_seq);
342N/A }
342N/A
342N/A double predict_scan_only_time_ms_during_cm(size_t scan_only_region_num) {
342N/A if (_cost_per_scan_only_region_ms_during_cm_seq->num() < 3)
342N/A return 1.5 * (double) scan_only_region_num *
342N/A get_new_prediction(_cost_per_scan_only_region_ms_seq);
342N/A else
342N/A return (double) scan_only_region_num *
342N/A get_new_prediction(_cost_per_scan_only_region_ms_during_cm_seq);
342N/A }
342N/A
342N/A double predict_scan_only_time_ms(size_t scan_only_region_num) {
342N/A if (_in_marking_window_im)
342N/A return predict_scan_only_time_ms_during_cm(scan_only_region_num);
342N/A else
342N/A return (double) scan_only_region_num *
342N/A get_new_prediction(_cost_per_scan_only_region_ms_seq);
342N/A }
342N/A
342N/A double predict_object_copy_time_ms_during_cm(size_t bytes_to_copy) {
342N/A if (_cost_per_byte_ms_during_cm_seq->num() < 3)
342N/A return 1.1 * (double) bytes_to_copy *
342N/A get_new_prediction(_cost_per_byte_ms_seq);
342N/A else
342N/A return (double) bytes_to_copy *
342N/A get_new_prediction(_cost_per_byte_ms_during_cm_seq);
342N/A }
342N/A
342N/A double predict_object_copy_time_ms(size_t bytes_to_copy) {
342N/A if (_in_marking_window && !_in_marking_window_im)
342N/A return predict_object_copy_time_ms_during_cm(bytes_to_copy);
342N/A else
342N/A return (double) bytes_to_copy *
342N/A get_new_prediction(_cost_per_byte_ms_seq);
342N/A }
342N/A
342N/A double predict_constant_other_time_ms() {
342N/A return get_new_prediction(_constant_other_time_ms_seq);
342N/A }
342N/A
342N/A double predict_young_other_time_ms(size_t young_num) {
342N/A return
342N/A (double) young_num *
342N/A get_new_prediction(_young_other_cost_per_region_ms_seq);
342N/A }
342N/A
342N/A double predict_non_young_other_time_ms(size_t non_young_num) {
342N/A return
342N/A (double) non_young_num *
342N/A get_new_prediction(_non_young_other_cost_per_region_ms_seq);
342N/A }
342N/A
342N/A void check_if_region_is_too_expensive(double predicted_time_ms);
342N/A
342N/A double predict_young_collection_elapsed_time_ms(size_t adjustment);
342N/A double predict_base_elapsed_time_ms(size_t pending_cards);
342N/A double predict_base_elapsed_time_ms(size_t pending_cards,
342N/A size_t scanned_cards);
342N/A size_t predict_bytes_to_copy(HeapRegion* hr);
342N/A double predict_region_elapsed_time_ms(HeapRegion* hr, bool young);
342N/A
342N/A // for use by: calculate_optimal_so_length(length)
342N/A void predict_gc_eff(size_t young_region_num,
342N/A size_t so_length,
342N/A double base_time_ms,
342N/A double *gc_eff,
342N/A double *pause_time_ms);
342N/A
342N/A // for use by: calculate_young_list_target_config(rs_length)
342N/A bool predict_gc_eff(size_t young_region_num,
342N/A size_t so_length,
342N/A double base_time_with_so_ms,
342N/A size_t init_free_regions,
342N/A double target_pause_time_ms,
342N/A double* gc_eff);
342N/A
342N/A void start_recording_regions();
342N/A void record_cset_region(HeapRegion* hr, bool young);
342N/A void record_scan_only_regions(size_t scan_only_length);
342N/A void end_recording_regions();
342N/A
342N/A void record_vtime_diff_ms(double vtime_diff_ms) {
342N/A _vtime_diff_ms = vtime_diff_ms;
342N/A }
342N/A
342N/A void record_young_free_cset_time_ms(double time_ms) {
342N/A _recorded_young_free_cset_time_ms = time_ms;
342N/A }
342N/A
342N/A void record_non_young_free_cset_time_ms(double time_ms) {
342N/A _recorded_non_young_free_cset_time_ms = time_ms;
342N/A }
342N/A
342N/A double predict_young_gc_eff() {
342N/A return get_new_neg_prediction(_young_gc_eff_seq);
342N/A }
342N/A
545N/A double predict_survivor_regions_evac_time();
545N/A
342N/A // </NEW PREDICTION>
342N/A
342N/Apublic:
342N/A void cset_regions_freed() {
342N/A bool propagate = _last_young_gc_full && !_in_marking_window;
342N/A _short_lived_surv_rate_group->all_surviving_words_recorded(propagate);
342N/A _survivor_surv_rate_group->all_surviving_words_recorded(propagate);
342N/A // also call it on any more surv rate groups
342N/A }
342N/A
342N/A void set_known_garbage_bytes(size_t known_garbage_bytes) {
342N/A _known_garbage_bytes = known_garbage_bytes;
342N/A size_t heap_bytes = _g1->capacity();
342N/A _known_garbage_ratio = (double) _known_garbage_bytes / (double) heap_bytes;
342N/A }
342N/A
342N/A void decrease_known_garbage_bytes(size_t known_garbage_bytes) {
342N/A guarantee( _known_garbage_bytes >= known_garbage_bytes, "invariant" );
342N/A
342N/A _known_garbage_bytes -= known_garbage_bytes;
342N/A size_t heap_bytes = _g1->capacity();
342N/A _known_garbage_ratio = (double) _known_garbage_bytes / (double) heap_bytes;
342N/A }
342N/A
342N/A G1MMUTracker* mmu_tracker() {
342N/A return _mmu_tracker;
342N/A }
342N/A
342N/A double predict_init_time_ms() {
342N/A return get_new_prediction(_concurrent_mark_init_times_ms);
342N/A }
342N/A
342N/A double predict_remark_time_ms() {
342N/A return get_new_prediction(_concurrent_mark_remark_times_ms);
342N/A }
342N/A
342N/A double predict_cleanup_time_ms() {
342N/A return get_new_prediction(_concurrent_mark_cleanup_times_ms);
342N/A }
342N/A
342N/A // Returns an estimate of the survival rate of the region at yg-age
342N/A // "yg_age".
545N/A double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) {
545N/A TruncatedSeq* seq = surv_rate_group->get_seq(age);
342N/A if (seq->num() == 0)
342N/A gclog_or_tty->print("BARF! age is %d", age);
342N/A guarantee( seq->num() > 0, "invariant" );
342N/A double pred = get_new_prediction(seq);
342N/A if (pred > 1.0)
342N/A pred = 1.0;
342N/A return pred;
342N/A }
342N/A
545N/A double predict_yg_surv_rate(int age) {
545N/A return predict_yg_surv_rate(age, _short_lived_surv_rate_group);
545N/A }
545N/A
342N/A double accum_yg_surv_rate_pred(int age) {
342N/A return _short_lived_surv_rate_group->accum_surv_rate_pred(age);
342N/A }
342N/A
342N/Aprotected:
342N/A void print_stats (int level, const char* str, double value);
342N/A void print_stats (int level, const char* str, int value);
342N/A void print_par_stats (int level, const char* str, double* data) {
342N/A print_par_stats(level, str, data, true);
342N/A }
342N/A void print_par_stats (int level, const char* str, double* data, bool summary);
342N/A void print_par_buffers (int level, const char* str, double* data, bool summary);
342N/A
342N/A void check_other_times(int level,
342N/A NumberSeq* other_times_ms,
342N/A NumberSeq* calc_other_times_ms) const;
342N/A
342N/A void print_summary (PauseSummary* stats) const;
342N/A void print_abandoned_summary(PauseSummary* non_pop_summary,
342N/A PauseSummary* pop_summary) const;
342N/A
342N/A void print_summary (int level, const char* str, NumberSeq* seq) const;
342N/A void print_summary_sd (int level, const char* str, NumberSeq* seq) const;
342N/A
342N/A double avg_value (double* data);
342N/A double max_value (double* data);
342N/A double sum_of_values (double* data);
342N/A double max_sum (double* data1, double* data2);
342N/A
342N/A int _last_satb_drain_processed_buffers;
342N/A int _last_update_rs_processed_buffers;
342N/A double _last_pause_time_ms;
342N/A
342N/A size_t _bytes_in_to_space_before_gc;
342N/A size_t _bytes_in_to_space_after_gc;
342N/A size_t bytes_in_to_space_during_gc() {
342N/A return
342N/A _bytes_in_to_space_after_gc - _bytes_in_to_space_before_gc;
342N/A }
342N/A size_t _bytes_in_collection_set_before_gc;
342N/A // Used to count used bytes in CS.
342N/A friend class CountCSClosure;
342N/A
342N/A // Statistics kept per GC stoppage, pause or full.
342N/A TruncatedSeq* _recent_prev_end_times_for_all_gcs_sec;
342N/A
342N/A // We track markings.
342N/A int _num_markings;
342N/A double _mark_thread_startup_sec; // Time at startup of marking thread
342N/A
342N/A // Add a new GC of the given duration and end time to the record.
342N/A void update_recent_gc_times(double end_time_sec, double elapsed_ms);
342N/A
342N/A // The head of the list (via "next_in_collection_set()") representing the
342N/A // current collection set.
342N/A HeapRegion* _collection_set;
342N/A size_t _collection_set_size;
342N/A size_t _collection_set_bytes_used_before;
342N/A
342N/A // Info about marking.
342N/A int _n_marks; // Sticky at 2, so we know when we've done at least 2.
342N/A
342N/A // The number of collection pauses at the end of the last mark.
342N/A size_t _n_pauses_at_mark_end;
342N/A
342N/A // ==== This section is for stats related to starting Conc Refinement on time.
342N/A size_t _conc_refine_enabled;
342N/A size_t _conc_refine_zero_traversals;
342N/A size_t _conc_refine_max_traversals;
342N/A // In # of heap regions.
342N/A size_t _conc_refine_current_delta;
342N/A
342N/A // At the beginning of a collection pause, update the variables above,
342N/A // especially the "delta".
342N/A void update_conc_refine_data();
342N/A // ====
342N/A
342N/A // Stash a pointer to the g1 heap.
342N/A G1CollectedHeap* _g1;
342N/A
342N/A // The average time in ms per collection pause, averaged over recent pauses.
342N/A double recent_avg_time_for_pauses_ms();
342N/A
342N/A // The average time in ms for processing CollectedHeap strong roots, per
342N/A // collection pause, averaged over recent pauses.
342N/A double recent_avg_time_for_CH_strong_ms();
342N/A
342N/A // The average time in ms for processing the G1 remembered set, per
342N/A // pause, averaged over recent pauses.
342N/A double recent_avg_time_for_G1_strong_ms();
342N/A
342N/A // The average time in ms for "evacuating followers", per pause, averaged
342N/A // over recent pauses.
342N/A double recent_avg_time_for_evac_ms();
342N/A
342N/A // The number of "recent" GCs recorded in the number sequences
342N/A int number_of_recent_gcs();
342N/A
342N/A // The average survival ratio, computed by the total number of bytes
342N/A // suriviving / total number of bytes before collection over the last
342N/A // several recent pauses.
342N/A double recent_avg_survival_fraction();
342N/A // The survival fraction of the most recent pause; if there have been no
342N/A // pauses, returns 1.0.
342N/A double last_survival_fraction();
342N/A
342N/A // Returns a "conservative" estimate of the recent survival rate, i.e.,
342N/A // one that may be higher than "recent_avg_survival_fraction".
342N/A // This is conservative in several ways:
342N/A // If there have been few pauses, it will assume a potential high
342N/A // variance, and err on the side of caution.
342N/A // It puts a lower bound (currently 0.1) on the value it will return.
342N/A // To try to detect phase changes, if the most recent pause ("latest") has a
342N/A // higher-than average ("avg") survival rate, it returns that rate.
342N/A // "work" version is a utility function; young is restricted to young regions.
342N/A double conservative_avg_survival_fraction_work(double avg,
342N/A double latest);
342N/A
342N/A // The arguments are the two sequences that keep track of the number of bytes
342N/A // surviving and the total number of bytes before collection, resp.,
342N/A // over the last evereal recent pauses
342N/A // Returns the survival rate for the category in the most recent pause.
342N/A // If there have been no pauses, returns 1.0.
342N/A double last_survival_fraction_work(TruncatedSeq* surviving,
342N/A TruncatedSeq* before);
342N/A
342N/A // The arguments are the two sequences that keep track of the number of bytes
342N/A // surviving and the total number of bytes before collection, resp.,
342N/A // over the last several recent pauses
342N/A // Returns the average survival ration over the last several recent pauses
342N/A // If there have been no pauses, return 1.0
342N/A double recent_avg_survival_fraction_work(TruncatedSeq* surviving,
342N/A TruncatedSeq* before);
342N/A
342N/A double conservative_avg_survival_fraction() {
342N/A double avg = recent_avg_survival_fraction();
342N/A double latest = last_survival_fraction();
342N/A return conservative_avg_survival_fraction_work(avg, latest);
342N/A }
342N/A
342N/A // The ratio of gc time to elapsed time, computed over recent pauses.
342N/A double _recent_avg_pause_time_ratio;
342N/A
342N/A double recent_avg_pause_time_ratio() {
342N/A return _recent_avg_pause_time_ratio;
342N/A }
342N/A
342N/A // Number of pauses between concurrent marking.
342N/A size_t _pauses_btwn_concurrent_mark;
342N/A
342N/A size_t _n_marks_since_last_pause;
342N/A
342N/A // True iff CM has been initiated.
342N/A bool _conc_mark_initiated;
342N/A
342N/A // True iff CM should be initiated
342N/A bool _should_initiate_conc_mark;
342N/A bool _should_revert_to_full_young_gcs;
342N/A bool _last_full_young_gc;
342N/A
342N/A // This set of variables tracks the collector efficiency, in order to
342N/A // determine whether we should initiate a new marking.
342N/A double _cur_mark_stop_world_time_ms;
342N/A double _mark_init_start_sec;
342N/A double _mark_remark_start_sec;
342N/A double _mark_cleanup_start_sec;
342N/A double _mark_closure_time_ms;
342N/A
342N/A void calculate_young_list_min_length();
342N/A void calculate_young_list_target_config();
342N/A void calculate_young_list_target_config(size_t rs_lengths);
342N/A size_t calculate_optimal_so_length(size_t young_list_length);
342N/A
342N/Apublic:
342N/A
342N/A G1CollectorPolicy();
342N/A
342N/A virtual G1CollectorPolicy* as_g1_policy() { return this; }
342N/A
342N/A virtual CollectorPolicy::Name kind() {
342N/A return CollectorPolicy::G1CollectorPolicyKind;
342N/A }
342N/A
342N/A void check_prediction_validity();
342N/A
342N/A size_t bytes_in_collection_set() {
342N/A return _bytes_in_collection_set_before_gc;
342N/A }
342N/A
342N/A size_t bytes_in_to_space() {
342N/A return bytes_in_to_space_during_gc();
342N/A }
342N/A
342N/A unsigned calc_gc_alloc_time_stamp() {
342N/A return _all_pause_times_ms->num() + 1;
342N/A }
342N/A
342N/Aprotected:
342N/A
342N/A // Count the number of bytes used in the CS.
342N/A void count_CS_bytes_used();
342N/A
342N/A // Together these do the base cleanup-recording work. Subclasses might
342N/A // want to put something between them.
342N/A void record_concurrent_mark_cleanup_end_work1(size_t freed_bytes,
342N/A size_t max_live_bytes);
342N/A void record_concurrent_mark_cleanup_end_work2();
342N/A
342N/Apublic:
342N/A
342N/A virtual void init();
342N/A
545N/A // Create jstat counters for the policy.
545N/A virtual void initialize_gc_policy_counters();
545N/A
342N/A virtual HeapWord* mem_allocate_work(size_t size,
342N/A bool is_tlab,
342N/A bool* gc_overhead_limit_was_exceeded);
342N/A
342N/A // This method controls how a collector handles one or more
342N/A // of its generations being fully allocated.
342N/A virtual HeapWord* satisfy_failed_allocation(size_t size,
342N/A bool is_tlab);
342N/A
342N/A BarrierSet::Name barrier_set_name() { return BarrierSet::G1SATBCTLogging; }
342N/A
342N/A GenRemSet::Name rem_set_name() { return GenRemSet::CardTable; }
342N/A
342N/A // The number of collection pauses so far.
342N/A long n_pauses() const { return _n_pauses; }
342N/A
342N/A // Update the heuristic info to record a collection pause of the given
342N/A // start time, where the given number of bytes were used at the start.
342N/A // This may involve changing the desired size of a collection set.
342N/A
342N/A virtual void record_stop_world_start();
342N/A
342N/A virtual void record_collection_pause_start(double start_time_sec,
342N/A size_t start_used);
342N/A
342N/A virtual void record_popular_pause_preamble_start();
342N/A virtual void record_popular_pause_preamble_end();
342N/A
342N/A // Must currently be called while the world is stopped.
342N/A virtual void record_concurrent_mark_init_start();
342N/A virtual void record_concurrent_mark_init_end();
342N/A void record_concurrent_mark_init_end_pre(double
342N/A mark_init_elapsed_time_ms);
342N/A
342N/A void record_mark_closure_time(double mark_closure_time_ms);
342N/A
342N/A virtual void record_concurrent_mark_remark_start();
342N/A virtual void record_concurrent_mark_remark_end();
342N/A
342N/A virtual void record_concurrent_mark_cleanup_start();
342N/A virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes,
342N/A size_t max_live_bytes);
342N/A virtual void record_concurrent_mark_cleanup_completed();
342N/A
342N/A virtual void record_concurrent_pause();
342N/A virtual void record_concurrent_pause_end();
342N/A
342N/A virtual void record_collection_pause_end_CH_strong_roots();
342N/A virtual void record_collection_pause_end_G1_strong_roots();
342N/A
342N/A virtual void record_collection_pause_end(bool popular, bool abandoned);
342N/A
342N/A // Record the fact that a full collection occurred.
342N/A virtual void record_full_collection_start();
342N/A virtual void record_full_collection_end();
342N/A
342N/A void record_ext_root_scan_time(int worker_i, double ms) {
342N/A _par_last_ext_root_scan_times_ms[worker_i] = ms;
342N/A }
342N/A
342N/A void record_mark_stack_scan_time(int worker_i, double ms) {
342N/A _par_last_mark_stack_scan_times_ms[worker_i] = ms;
342N/A }
342N/A
342N/A void record_scan_only_time(int worker_i, double ms, int n) {
342N/A _par_last_scan_only_times_ms[worker_i] = ms;
342N/A _par_last_scan_only_regions_scanned[worker_i] = (double) n;
342N/A }
342N/A
342N/A void record_satb_drain_time(double ms) {
342N/A _cur_satb_drain_time_ms = ms;
342N/A _satb_drain_time_set = true;
342N/A }
342N/A
342N/A void record_satb_drain_processed_buffers (int processed_buffers) {
342N/A _last_satb_drain_processed_buffers = processed_buffers;
342N/A }
342N/A
342N/A void record_mod_union_time(double ms) {
342N/A _all_mod_union_times_ms->add(ms);
342N/A }
342N/A
342N/A void record_update_rs_start_time(int thread, double ms) {
342N/A _par_last_update_rs_start_times_ms[thread] = ms;
342N/A }
342N/A
342N/A void record_update_rs_time(int thread, double ms) {
342N/A _par_last_update_rs_times_ms[thread] = ms;
342N/A }
342N/A
342N/A void record_update_rs_processed_buffers (int thread,
342N/A double processed_buffers) {
342N/A _par_last_update_rs_processed_buffers[thread] = processed_buffers;
342N/A }
342N/A
342N/A void record_scan_rs_start_time(int thread, double ms) {
342N/A _par_last_scan_rs_start_times_ms[thread] = ms;
342N/A }
342N/A
342N/A void record_scan_rs_time(int thread, double ms) {
342N/A _par_last_scan_rs_times_ms[thread] = ms;
342N/A }
342N/A
342N/A void record_scan_new_refs_time(int thread, double ms) {
342N/A _par_last_scan_new_refs_times_ms[thread] = ms;
342N/A }
342N/A
342N/A double get_scan_new_refs_time(int thread) {
342N/A return _par_last_scan_new_refs_times_ms[thread];
342N/A }
342N/A
342N/A void reset_obj_copy_time(int thread) {
342N/A _par_last_obj_copy_times_ms[thread] = 0.0;
342N/A }
342N/A
342N/A void reset_obj_copy_time() {
342N/A reset_obj_copy_time(0);
342N/A }
342N/A
342N/A void record_obj_copy_time(int thread, double ms) {
342N/A _par_last_obj_copy_times_ms[thread] += ms;
342N/A }
342N/A
342N/A void record_obj_copy_time(double ms) {
342N/A record_obj_copy_time(0, ms);
342N/A }
342N/A
342N/A void record_termination_time(int thread, double ms) {
342N/A _par_last_termination_times_ms[thread] = ms;
342N/A }
342N/A
342N/A void record_termination_time(double ms) {
342N/A record_termination_time(0, ms);
342N/A }
342N/A
342N/A void record_pause_time(double ms) {
342N/A _last_pause_time_ms = ms;
342N/A }
342N/A
342N/A void record_clear_ct_time(double ms) {
342N/A _cur_clear_ct_time_ms = ms;
342N/A }
342N/A
342N/A void record_par_time(double ms) {
342N/A _cur_collection_par_time_ms = ms;
342N/A }
342N/A
342N/A void record_aux_start_time(int i) {
342N/A guarantee(i < _aux_num, "should be within range");
342N/A _cur_aux_start_times_ms[i] = os::elapsedTime() * 1000.0;
342N/A }
342N/A
342N/A void record_aux_end_time(int i) {
342N/A guarantee(i < _aux_num, "should be within range");
342N/A double ms = os::elapsedTime() * 1000.0 - _cur_aux_start_times_ms[i];
342N/A _cur_aux_times_set[i] = true;
342N/A _cur_aux_times_ms[i] += ms;
342N/A }
342N/A
342N/A void record_pop_compute_rc_start();
342N/A void record_pop_compute_rc_end();
342N/A
342N/A void record_pop_evac_start();
342N/A void record_pop_evac_end();
342N/A
342N/A // Record the fact that "bytes" bytes allocated in a region.
342N/A void record_before_bytes(size_t bytes);
342N/A void record_after_bytes(size_t bytes);
342N/A
342N/A // Returns "true" if this is a good time to do a collection pause.
342N/A // The "word_size" argument, if non-zero, indicates the size of an
342N/A // allocation request that is prompting this query.
342N/A virtual bool should_do_collection_pause(size_t word_size) = 0;
342N/A
342N/A // Choose a new collection set. Marks the chosen regions as being
342N/A // "in_collection_set", and links them together. The head and number of
342N/A // the collection set are available via access methods.
342N/A // If "pop_region" is non-NULL, it is a popular region that has already
342N/A // been added to the collection set.
342N/A virtual void choose_collection_set(HeapRegion* pop_region = NULL) = 0;
342N/A
342N/A void clear_collection_set() { _collection_set = NULL; }
342N/A
342N/A // The head of the list (via "next_in_collection_set()") representing the
342N/A // current collection set.
342N/A HeapRegion* collection_set() { return _collection_set; }
342N/A
342N/A // Sets the collection set to the given single region.
342N/A virtual void set_single_region_collection_set(HeapRegion* hr);
342N/A
342N/A // The number of elements in the current collection set.
342N/A size_t collection_set_size() { return _collection_set_size; }
342N/A
342N/A // Add "hr" to the CS.
342N/A void add_to_collection_set(HeapRegion* hr);
342N/A
342N/A bool should_initiate_conc_mark() { return _should_initiate_conc_mark; }
342N/A void set_should_initiate_conc_mark() { _should_initiate_conc_mark = true; }
342N/A void unset_should_initiate_conc_mark(){ _should_initiate_conc_mark = false; }
342N/A
342N/A void checkpoint_conc_overhead();
342N/A
342N/A // If an expansion would be appropriate, because recent GC overhead had
342N/A // exceeded the desired limit, return an amount to expand by.
342N/A virtual size_t expansion_amount();
342N/A
342N/A // note start of mark thread
342N/A void note_start_of_mark_thread();
342N/A
342N/A // The marked bytes of the "r" has changed; reclassify it's desirability
342N/A // for marking. Also asserts that "r" is eligible for a CS.
342N/A virtual void note_change_in_marked_bytes(HeapRegion* r) = 0;
342N/A
342N/A#ifndef PRODUCT
342N/A // Check any appropriate marked bytes info, asserting false if
342N/A // something's wrong, else returning "true".
342N/A virtual bool assertMarkedBytesDataOK() = 0;
342N/A#endif
342N/A
342N/A // Print tracing information.
342N/A void print_tracing_info() const;
342N/A
342N/A // Print stats on young survival ratio
342N/A void print_yg_surv_rate_info() const;
342N/A
545N/A void finished_recalculating_age_indexes(bool is_survivors) {
545N/A if (is_survivors) {
545N/A _survivor_surv_rate_group->finished_recalculating_age_indexes();
545N/A } else {
545N/A _short_lived_surv_rate_group->finished_recalculating_age_indexes();
545N/A }
342N/A // do that for any other surv rate groups
342N/A }
342N/A
342N/A bool should_add_next_region_to_young_list();
342N/A
342N/A bool in_young_gc_mode() {
342N/A return _in_young_gc_mode;
342N/A }
342N/A void set_in_young_gc_mode(bool in_young_gc_mode) {
342N/A _in_young_gc_mode = in_young_gc_mode;
342N/A }
342N/A
342N/A bool full_young_gcs() {
342N/A return _full_young_gcs;
342N/A }
342N/A void set_full_young_gcs(bool full_young_gcs) {
342N/A _full_young_gcs = full_young_gcs;
342N/A }
342N/A
342N/A bool adaptive_young_list_length() {
342N/A return _adaptive_young_list_length;
342N/A }
342N/A void set_adaptive_young_list_length(bool adaptive_young_list_length) {
342N/A _adaptive_young_list_length = adaptive_young_list_length;
342N/A }
342N/A
342N/A inline double get_gc_eff_factor() {
342N/A double ratio = _known_garbage_ratio;
342N/A
342N/A double square = ratio * ratio;
342N/A // square = square * square;
342N/A double ret = square * 9.0 + 1.0;
342N/A#if 0
342N/A gclog_or_tty->print_cr("ratio = %1.2lf, ret = %1.2lf", ratio, ret);
342N/A#endif // 0
342N/A guarantee(0.0 <= ret && ret < 10.0, "invariant!");
342N/A return ret;
342N/A }
342N/A
342N/A //
342N/A // Survivor regions policy.
342N/A //
342N/Aprotected:
342N/A
342N/A // Current tenuring threshold, set to 0 if the collector reaches the
342N/A // maximum amount of suvivors regions.
342N/A int _tenuring_threshold;
342N/A
545N/A // The limit on the number of regions allocated for survivors.
545N/A size_t _max_survivor_regions;
545N/A
545N/A // The amount of survor regions after a collection.
545N/A size_t _recorded_survivor_regions;
545N/A // List of survivor regions.
545N/A HeapRegion* _recorded_survivor_head;
545N/A HeapRegion* _recorded_survivor_tail;
545N/A
545N/A ageTable _survivors_age_table;
545N/A
342N/Apublic:
342N/A
342N/A inline GCAllocPurpose
342N/A evacuation_destination(HeapRegion* src_region, int age, size_t word_sz) {
342N/A if (age < _tenuring_threshold && src_region->is_young()) {
342N/A return GCAllocForSurvived;
342N/A } else {
342N/A return GCAllocForTenured;
342N/A }
342N/A }
342N/A
342N/A inline bool track_object_age(GCAllocPurpose purpose) {
342N/A return purpose == GCAllocForSurvived;
342N/A }
342N/A
342N/A inline GCAllocPurpose alternative_purpose(int purpose) {
342N/A return GCAllocForTenured;
342N/A }
342N/A
545N/A static const size_t REGIONS_UNLIMITED = ~(size_t)0;
545N/A
545N/A size_t max_regions(int purpose);
342N/A
342N/A // The limit on regions for a particular purpose is reached.
342N/A void note_alloc_region_limit_reached(int purpose) {
342N/A if (purpose == GCAllocForSurvived) {
342N/A _tenuring_threshold = 0;
342N/A }
342N/A }
342N/A
342N/A void note_start_adding_survivor_regions() {
342N/A _survivor_surv_rate_group->start_adding_regions();
342N/A }
342N/A
342N/A void note_stop_adding_survivor_regions() {
342N/A _survivor_surv_rate_group->stop_adding_regions();
342N/A }
545N/A
545N/A void record_survivor_regions(size_t regions,
545N/A HeapRegion* head,
545N/A HeapRegion* tail) {
545N/A _recorded_survivor_regions = regions;
545N/A _recorded_survivor_head = head;
545N/A _recorded_survivor_tail = tail;
545N/A }
545N/A
545N/A void record_thread_age_table(ageTable* age_table)
545N/A {
545N/A _survivors_age_table.merge_par(age_table);
545N/A }
545N/A
545N/A // Calculates survivor space parameters.
545N/A void calculate_survivors_policy();
545N/A
342N/A};
342N/A
342N/A// This encapsulates a particular strategy for a g1 Collector.
342N/A//
342N/A// Start a concurrent mark when our heap size is n bytes
342N/A// greater then our heap size was at the last concurrent
342N/A// mark. Where n is a function of the CMSTriggerRatio
342N/A// and the MinHeapFreeRatio.
342N/A//
342N/A// Start a g1 collection pause when we have allocated the
342N/A// average number of bytes currently being freed in
342N/A// a collection, but only if it is at least one region
342N/A// full
342N/A//
342N/A// Resize Heap based on desired
342N/A// allocation space, where desired allocation space is
342N/A// a function of survival rate and desired future to size.
342N/A//
342N/A// Choose collection set by first picking all older regions
342N/A// which have a survival rate which beats our projected young
342N/A// survival rate. Then fill out the number of needed regions
342N/A// with young regions.
342N/A
342N/Aclass G1CollectorPolicy_BestRegionsFirst: public G1CollectorPolicy {
342N/A CollectionSetChooser* _collectionSetChooser;
342N/A // If the estimated is less then desirable, resize if possible.
342N/A void expand_if_possible(size_t numRegions);
342N/A
342N/A virtual void choose_collection_set(HeapRegion* pop_region = NULL);
342N/A virtual void record_collection_pause_start(double start_time_sec,
342N/A size_t start_used);
342N/A virtual void record_concurrent_mark_cleanup_end(size_t freed_bytes,
342N/A size_t max_live_bytes);
342N/A virtual void record_full_collection_end();
342N/A
342N/Apublic:
342N/A G1CollectorPolicy_BestRegionsFirst() {
342N/A _collectionSetChooser = new CollectionSetChooser();
342N/A }
342N/A void record_collection_pause_end(bool popular, bool abandoned);
342N/A bool should_do_collection_pause(size_t word_size);
342N/A virtual void set_single_region_collection_set(HeapRegion* hr);
342N/A // This is not needed any more, after the CSet choosing code was
342N/A // changed to use the pause prediction work. But let's leave the
342N/A // hook in just in case.
342N/A void note_change_in_marked_bytes(HeapRegion* r) { }
342N/A#ifndef PRODUCT
342N/A bool assertMarkedBytesDataOK();
342N/A#endif
342N/A};
342N/A
342N/A// This should move to some place more general...
342N/A
342N/A// If we have "n" measurements, and we've kept track of their "sum" and the
342N/A// "sum_of_squares" of the measurements, this returns the variance of the
342N/A// sequence.
342N/Ainline double variance(int n, double sum_of_squares, double sum) {
342N/A double n_d = (double)n;
342N/A double avg = sum/n_d;
342N/A return (sum_of_squares - 2.0 * avg * sum + n_d * avg * avg) / n_d;
342N/A}
342N/A
342N/A// Local Variables: ***
342N/A// c-indentation-style: gnu ***
342N/A// End: ***