g1CollectorPolicy.hpp revision 2816
342N/A/*
2655N/A * Copyright (c) 2001, 2011, Oracle and/or its affiliates. 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 *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
342N/A *
342N/A */
342N/A
1879N/A#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
1879N/A#define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP
1879N/A
1879N/A#include "gc_implementation/g1/collectionSetChooser.hpp"
1879N/A#include "gc_implementation/g1/g1MMUTracker.hpp"
1879N/A#include "memory/collectorPolicy.hpp"
1879N/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/A
549N/Aclass PauseSummary: public CHeapObj {
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};
342N/A
549N/Aclass MainBodySummary: public CHeapObj {
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(update_rs)
342N/A define_num_seq(scan_rs)
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
677N/Aclass Summary: public PauseSummary,
677N/A public MainBodySummary {
342N/Apublic:
342N/A virtual MainBodySummary* main_body_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 {
942N/A NumPrevPausesForHeuristics = 10
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 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;
2815N/A double _cur_ref_proc_time_ms;
2815N/A double _cur_ref_enq_time_ms;
342N/A
890N/A#ifndef PRODUCT
890N/A // Card Table Count Cache stats
890N/A double _min_clear_cc_time_ms; // min
890N/A double _max_clear_cc_time_ms; // max
890N/A double _cur_clear_cc_time_ms; // clearing time during current pause
890N/A double _cum_clear_cc_time_ms; // cummulative clearing time
890N/A jlong _num_cc_clears; // number of times the card count cache has been cleared
890N/A#endif
890N/A
2648N/A // Statistics for recent GC pauses. See below for how indexed.
2648N/A TruncatedSeq* _recent_rs_scan_times_ms;
342N/A
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_remark_times_ms;
342N/A TruncatedSeq* _concurrent_mark_cleanup_times_ms;
342N/A
677N/A Summary* _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
1531N/A double* _par_last_gc_worker_start_times_ms;
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_update_rs_times_ms;
342N/A double* _par_last_update_rs_processed_buffers;
342N/A double* _par_last_scan_rs_times_ms;
342N/A double* _par_last_obj_copy_times_ms;
342N/A double* _par_last_termination_times_ms;
1531N/A double* _par_last_termination_attempts;
1531N/A double* _par_last_gc_worker_end_times_ms;
2277N/A double* _par_last_gc_worker_times_ms;
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_target_length;
342N/A size_t _young_list_fixed_length;
2754N/A size_t _prev_eden_capacity; // used for logging
342N/A
1898N/A // The max number of regions we can extend the eden by while the GC
1898N/A // locker is active. This should be >= _young_list_target_length;
1898N/A size_t _young_list_max_length;
1898N/A
342N/A size_t _young_cset_length;
342N/A bool _last_young_gc_full;
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
1356N/A double _gc_overhead_perc;
1356N/A
2753N/A double _reserve_factor;
2753N/A size_t _reserve_regions;
2753N/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* _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
342N/A TruncatedSeq* _young_gc_eff_seq;
342N/A
342N/A TruncatedSeq* _max_conc_overhead_seq;
342N/A
2754N/A bool _using_new_ratio_calculations;
2754N/A size_t _min_desired_young_length; // as set on the command line or default calculations
2754N/A size_t _max_desired_young_length; // as set on the command line or default calculations
2754N/A
342N/A size_t _recorded_young_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
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_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
1111N/A void adjust_concurrent_refinement(double update_rs_time,
1111N/A double update_rs_processed_buffers,
1111N/A double goal_ms);
1111N/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 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_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 void start_recording_regions();
1394N/A void record_cset_region_info(HeapRegion* hr, bool young);
1394N/A void record_non_young_cset_region(HeapRegion* hr);
1394N/A
1394N/A void set_recorded_young_regions(size_t n_regions);
1394N/A void set_recorded_young_bytes(size_t bytes);
1394N/A void set_recorded_rs_lengths(size_t rs_lengths);
1394N/A void set_predicted_bytes_to_copy(size_t bytes);
1394N/A
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/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
1576N/A double max_pause_time_ms() {
1576N/A return _mmu_tracker->max_gc_time() * 1000.0;
1576N/A }
1576N/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:
1531N/A void print_stats(int level, const char* str, double value);
1531N/A void print_stats(int level, const char* str, int value);
1531N/A
2277N/A void print_par_stats(int level, const char* str, double* data);
2277N/A void print_par_sizes(int level, const char* str, double* data);
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
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_collection_set_before_gc;
2655N/A size_t _bytes_copied_during_gc;
2655N/A
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
1394N/A // current collection set. Set from the incrementally built collection
1394N/A // set at the start of the pause.
342N/A HeapRegion* _collection_set;
1394N/A
1394N/A // The number of regions in the collection set. Set from the incrementally
1394N/A // built collection set at the start of an evacuation pause.
342N/A size_t _collection_set_size;
1394N/A
1394N/A // The number of bytes in the collection set before the pause. Set from
1394N/A // the incrementally built collection set at the start of an evacuation
1394N/A // pause.
342N/A size_t _collection_set_bytes_used_before;
342N/A
1394N/A // The associated information that is maintained while the incremental
1394N/A // collection set is being built with young regions. Used to populate
1394N/A // the recorded info for the evacuation pause.
1394N/A
1394N/A enum CSetBuildType {
1394N/A Active, // We are actively building the collection set
1394N/A Inactive // We are not actively building the collection set
1394N/A };
1394N/A
1394N/A CSetBuildType _inc_cset_build_state;
1394N/A
1394N/A // The head of the incrementally built collection set.
1394N/A HeapRegion* _inc_cset_head;
1394N/A
1394N/A // The tail of the incrementally built collection set.
1394N/A HeapRegion* _inc_cset_tail;
1394N/A
1394N/A // The number of regions in the incrementally built collection set.
1394N/A // Used to set _collection_set_size at the start of an evacuation
1394N/A // pause.
1394N/A size_t _inc_cset_size;
1394N/A
1394N/A // Used as the index in the surving young words structure
1394N/A // which tracks the amount of space, for each young region,
1394N/A // that survives the pause.
1394N/A size_t _inc_cset_young_index;
1394N/A
1394N/A // The number of bytes in the incrementally built collection set.
1394N/A // Used to set _collection_set_bytes_used_before at the start of
1394N/A // an evacuation pause.
1394N/A size_t _inc_cset_bytes_used_before;
1394N/A
1394N/A // Used to record the highest end of heap region in collection set
1394N/A HeapWord* _inc_cset_max_finger;
1394N/A
1394N/A // The number of recorded used bytes in the young regions
1394N/A // of the collection set. This is the sum of the used() bytes
1394N/A // of retired young regions in the collection set.
1394N/A size_t _inc_cset_recorded_young_bytes;
1394N/A
1394N/A // The RSet lengths recorded for regions in the collection set
1394N/A // (updated by the periodic sampling of the regions in the
1394N/A // young list/collection set).
1394N/A size_t _inc_cset_recorded_rs_lengths;
1394N/A
1394N/A // The predicted elapsed time it will take to collect the regions
1394N/A // in the collection set (updated by the periodic sampling of the
1394N/A // regions in the young list/collection set).
1394N/A double _inc_cset_predicted_elapsed_time_ms;
1394N/A
1394N/A // The predicted bytes to copy for the regions in the collection
1394N/A // set (updated by the periodic sampling of the regions in the
1394N/A // young list/collection set).
1394N/A size_t _inc_cset_predicted_bytes_to_copy;
1394N/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 // 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
2648N/A // The average time in ms for RS scanning, per pause, averaged
2648N/A // over recent pauses. (Note the RS scanning time for a pause
2648N/A // is itself an average of the RS scanning time for each worker
2648N/A // thread.)
2648N/A double recent_avg_time_for_rs_scan_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
1359N/A // At the end of a pause we check the heap occupancy and we decide
1359N/A // whether we will start a marking cycle during the next pause. If
1359N/A // we decide that we want to do that, we will set this parameter to
1359N/A // true. So, this parameter will stay true between the end of a
1359N/A // pause and the beginning of a subsequent pause (not necessarily
1359N/A // the next one, see the comments on the next field) when we decide
1359N/A // that we will indeed start a marking cycle and do the initial-mark
1359N/A // work.
1359N/A volatile bool _initiate_conc_mark_if_possible;
342N/A
1359N/A // If initiate_conc_mark_if_possible() is set at the beginning of a
1359N/A // pause, it is a suggestion that the pause should start a marking
1359N/A // cycle by doing the initial-mark work. However, it is possible
1359N/A // that the concurrent marking thread is still finishing up the
1359N/A // previous marking cycle (e.g., clearing the next marking
1359N/A // bitmap). If that is the case we cannot start a new cycle and
1359N/A // we'll have to wait for the concurrent marking thread to finish
1359N/A // what it is doing. In this case we will postpone the marking cycle
1359N/A // initiation decision for the next pause. When we eventually decide
1359N/A // to start a cycle, we will set _during_initial_mark_pause which
1359N/A // will stay true until the end of the initial-mark pause and it's
1359N/A // the condition that indicates that a pause is doing the
1359N/A // initial-mark work.
1359N/A volatile bool _during_initial_mark_pause;
1359N/A
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_remark_start_sec;
342N/A double _mark_cleanup_start_sec;
342N/A double _mark_closure_time_ms;
342N/A
2753N/A // Update the young list target length either by setting it to the
2753N/A // desired fixed value or by calculating it using G1's pause
2753N/A // prediction model. If no rs_lengths parameter is passed, predict
2753N/A // the RS lengths using the prediction model, otherwise use the
2753N/A // given rs_lengths as the prediction.
2753N/A void update_young_list_target_length(size_t rs_lengths = (size_t) -1);
2753N/A
2753N/A // Calculate and return the minimum desired young list target
2753N/A // length. This is the minimum desired young list length according
2753N/A // to the user's inputs.
2753N/A size_t calculate_young_list_desired_min_length(size_t base_min_length);
2753N/A
2753N/A // Calculate and return the maximum desired young list target
2753N/A // length. This is the maximum desired young list length according
2753N/A // to the user's inputs.
2753N/A size_t calculate_young_list_desired_max_length();
2753N/A
2753N/A // Calculate and return the maximum young list target length that
2753N/A // can fit into the pause time goal. The parameters are: rs_lengths
2753N/A // represent the prediction of how large the young RSet lengths will
2753N/A // be, base_min_length is the alreay existing number of regions in
2753N/A // the young list, min_length and max_length are the desired min and
2753N/A // max young list length according to the user's inputs.
2753N/A size_t calculate_young_list_target_length(size_t rs_lengths,
2753N/A size_t base_min_length,
2753N/A size_t desired_min_length,
2753N/A size_t desired_max_length);
2753N/A
2753N/A // Check whether a given young length (young_length) fits into the
2753N/A // given target pause time and whether the prediction for the amount
2753N/A // of objects to be copied for the given length will fit into the
2753N/A // given free space (expressed by base_free_regions). It is used by
2753N/A // calculate_young_list_target_length().
2753N/A bool predict_will_fit(size_t young_length, double base_time_ms,
2753N/A size_t base_free_regions, double target_pause_time_ms);
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
2753N/A // Check the current value of the young list RSet lengths and
2753N/A // compare it against the last prediction. If the current value is
2753N/A // higher, recalculate the young list target length prediction.
2753N/A void revise_young_list_target_length_if_necessary();
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 unsigned calc_gc_alloc_time_stamp() {
342N/A return _all_pause_times_ms->num() + 1;
342N/A }
342N/A
2754N/A // This should be called after the heap is resized.
2754N/A void record_new_heap_size(size_t new_number_of_regions);
2753N/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
2754N/A void update_young_list_size_using_newratio(size_t number_of_heap_regions);
2754N/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 // Must currently be called while the world is stopped.
2695N/A void record_concurrent_mark_init_end(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
1627N/A virtual void record_collection_pause_end();
2589N/A void print_heap_transition();
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
1531N/A void record_gc_worker_start_time(int worker_i, double ms) {
1531N/A _par_last_gc_worker_start_times_ms[worker_i] = ms;
1531N/A }
1531N/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_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_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_time(int thread, double ms) {
342N/A _par_last_scan_rs_times_ms[thread] = ms;
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
1531N/A void record_termination(int thread, double ms, size_t attempts) {
1531N/A _par_last_termination_times_ms[thread] = ms;
1531N/A _par_last_termination_attempts[thread] = (double) attempts;
342N/A }
342N/A
1531N/A void record_gc_worker_end_time(int worker_i, double ms) {
1531N/A _par_last_gc_worker_end_times_ms[worker_i] = ms;
342N/A }
342N/A
595N/A void record_pause_time_ms(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
2815N/A void record_ref_proc_time(double ms) {
2815N/A _cur_ref_proc_time_ms = ms;
2815N/A }
2815N/A
2815N/A void record_ref_enq_time(double ms) {
2815N/A _cur_ref_enq_time_ms = ms;
2815N/A }
2815N/A
890N/A#ifndef PRODUCT
890N/A void record_cc_clear_time(double ms) {
890N/A if (_min_clear_cc_time_ms < 0.0 || ms <= _min_clear_cc_time_ms)
890N/A _min_clear_cc_time_ms = ms;
890N/A if (_max_clear_cc_time_ms < 0.0 || ms >= _max_clear_cc_time_ms)
890N/A _max_clear_cc_time_ms = ms;
890N/A _cur_clear_cc_time_ms = ms;
890N/A _cum_clear_cc_time_ms += ms;
890N/A _num_cc_clears++;
890N/A }
890N/A#endif
890N/A
2655N/A // Record how much space we copied during a GC. This is typically
2655N/A // called when a GC alloc region is being retired.
2655N/A void record_bytes_copied_during_gc(size_t bytes) {
2655N/A _bytes_copied_during_gc += bytes;
2655N/A }
2655N/A
2655N/A // The amount of space we copied during a GC.
2655N/A size_t bytes_copied_during_gc() {
2655N/A return _bytes_copied_during_gc;
2655N/A }
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.
1627N/A virtual void choose_collection_set(double target_pause_time_ms) = 0;
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
1394N/A void clear_collection_set() { _collection_set = NULL; }
1394N/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
1394N/A // Incremental CSet Support
1394N/A
1394N/A // The head of the incrementally built collection set.
1394N/A HeapRegion* inc_cset_head() { return _inc_cset_head; }
1394N/A
1394N/A // The tail of the incrementally built collection set.
1394N/A HeapRegion* inc_set_tail() { return _inc_cset_tail; }
1394N/A
1394N/A // The number of elements in the incrementally built collection set.
1394N/A size_t inc_cset_size() { return _inc_cset_size; }
1394N/A
1394N/A // Initialize incremental collection set info.
1394N/A void start_incremental_cset_building();
1394N/A
1394N/A void clear_incremental_cset() {
1394N/A _inc_cset_head = NULL;
1394N/A _inc_cset_tail = NULL;
1394N/A }
1394N/A
1394N/A // Stop adding regions to the incremental collection set
1394N/A void stop_incremental_cset_building() { _inc_cset_build_state = Inactive; }
1394N/A
1394N/A // Add/remove information about hr to the aggregated information
1394N/A // for the incrementally built collection set.
1394N/A void add_to_incremental_cset_info(HeapRegion* hr, size_t rs_length);
1394N/A void remove_from_incremental_cset_info(HeapRegion* hr);
1394N/A
1394N/A // Update information about hr in the aggregated information for
1394N/A // the incrementally built collection set.
1394N/A void update_incremental_cset_info(HeapRegion* hr, size_t new_rs_length);
1394N/A
1394N/Aprivate:
1394N/A // Update the incremental cset information when adding a region
1394N/A // (should not be called directly).
1394N/A void add_region_to_incremental_cset_common(HeapRegion* hr);
1394N/A
1394N/Apublic:
1394N/A // Add hr to the LHS of the incremental collection set.
1394N/A void add_region_to_incremental_cset_lhs(HeapRegion* hr);
1394N/A
1394N/A // Add hr to the RHS of the incremental collection set.
1394N/A void add_region_to_incremental_cset_rhs(HeapRegion* hr);
1394N/A
1394N/A#ifndef PRODUCT
1394N/A void print_collection_set(HeapRegion* list_head, outputStream* st);
1394N/A#endif // !PRODUCT
1394N/A
1359N/A bool initiate_conc_mark_if_possible() { return _initiate_conc_mark_if_possible; }
1359N/A void set_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = true; }
1359N/A void clear_initiate_conc_mark_if_possible() { _initiate_conc_mark_if_possible = false; }
1359N/A
1359N/A bool during_initial_mark_pause() { return _during_initial_mark_pause; }
1359N/A void set_during_initial_mark_pause() { _during_initial_mark_pause = true; }
1359N/A void clear_during_initial_mark_pause(){ _during_initial_mark_pause = false; }
1359N/A
1576N/A // This sets the initiate_conc_mark_if_possible() flag to start a
1576N/A // new cycle, as long as we are not already in one. It's best if it
1576N/A // is called during a safepoint when the test whether a cycle is in
1576N/A // progress or not is stable.
2748N/A bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause);
1576N/A
1359N/A // This is called at the very beginning of an evacuation pause (it
1359N/A // has to be the first thing that the pause does). If
1359N/A // initiate_conc_mark_if_possible() is true, and the concurrent
1359N/A // marking thread has completed its work during the previous cycle,
1359N/A // it will set during_initial_mark_pause() to so that the pause does
1359N/A // the initial-mark work and start a marking cycle.
1359N/A void decide_on_conc_mark_initiation();
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
1880N/A bool is_young_list_full() {
1880N/A size_t young_list_length = _g1->young_list()->length();
1898N/A size_t young_list_target_length = _young_list_target_length;
1898N/A return young_list_length >= young_list_target_length;
1898N/A }
1898N/A
1898N/A bool can_expand_young_list() {
1898N/A size_t young_list_length = _g1->young_list()->length();
1898N/A size_t young_list_max_length = _young_list_max_length;
1898N/A return young_list_length < young_list_max_length;
1898N/A }
1880N/A
2816N/A size_t young_list_max_length() {
2816N/A return _young_list_max_length;
2816N/A }
2816N/A
1880N/A void update_region_num(bool young);
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
2589N/A // For reporting purposes.
2589N/A size_t _eden_bytes_before_gc;
2589N/A size_t _survivor_bytes_before_gc;
2589N/A size_t _capacity_before_gc;
2589N/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
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
838N/A size_t recorded_survivor_regions() {
838N/A return _recorded_survivor_regions;
838N/A }
838N/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
2753N/A void update_max_gc_locker_expansion();
1898N/A
545N/A // Calculates survivor space parameters.
2753N/A void update_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
1627N/A virtual void choose_collection_set(double target_pause_time_ms);
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 }
1627N/A void record_collection_pause_end();
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
1879N/A#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP