g1CollectorPolicy.hpp revision 2816
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 * 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 * 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 * 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. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 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// 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 // The number of pauses during the execution. 342N/A // either equal to the number of parallel threads, if ParallelGCThreads 342N/A // has been set, or 1 otherwise 342N/A // Pick some reasonable default. 890N/A // Card Table Count Cache stats 2648N/A // Statistics for recent GC pauses. See below for how indexed. 342N/A // These exclude marking times. 342N/A // indicates whether we are in full young or partially young GC mode 342N/A // if true, then it tries to dynamically adjust the length of the 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; 342N/A // add here any more surv rate groups 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 // also call it on any more surv rate groups 342N/A // Returns an estimate of the survival rate of the region at yg-age 342N/A // Used to count used bytes in CS. 342N/A // Statistics kept per GC stoppage, pause or full. 342N/A // Add a new GC of the given duration and end time to the record. 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. 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. 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 // 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 // The head of the incrementally built collection set. 1394N/A // The tail of the incrementally built collection set. 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 // 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 // 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 // Used to record the highest end of heap region in collection set 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 // The RSet lengths recorded for regions in the collection set 1394N/A // (updated by the periodic sampling of the regions in the 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 // The predicted bytes to copy for the regions in the collection 1394N/A // set (updated by the periodic sampling of the regions in the 342N/A int _n_marks;
// Sticky at 2, so we know when we've done at least 2. 342N/A // The number of collection pauses at the end of the last mark. 342N/A // Stash a pointer to the g1 heap. 342N/A // The average time in ms per collection pause, averaged over recent pauses. 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 342N/A // The number of "recent" GCs recorded in the number sequences 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 // The survival fraction of the most recent pause; if there have been no 342N/A // pauses, returns 1.0. 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 // 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 // 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 // The ratio of gc time to elapsed time, computed over recent pauses. 342N/A // Number of pauses between concurrent marking. 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 // 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 342N/A // This set of variables tracks the collector efficiency, in order to 342N/A // determine whether we should initiate a new marking. 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 // Calculate and return the minimum desired young list target 2753N/A // length. This is the minimum desired young list length according 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 // 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 // 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 // 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. 2754N/A // This should be called after the heap is resized. 342N/A // Count the number of bytes used in the CS. 342N/A // Together these do the base cleanup-recording work. Subclasses might 342N/A // want to put something between them. 545N/A // Create jstat counters for the policy. 342N/A // This method controls how a collector handles one or more 342N/A // of its generations being fully allocated. 342N/A // The number of collection pauses so far. 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 // Must currently be called while the world is stopped. 342N/A // Record the fact that a full collection occurred. 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 // The amount of space we copied during a GC. 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 // The head of the list (via "next_in_collection_set()") representing the 342N/A // current collection set. 342N/A // The number of elements in the current collection set. 1394N/A // Incremental CSet Support 1394N/A // The head of the incrementally built collection set. 1394N/A // The tail of the incrementally built collection set. 1394N/A // The number of elements in the incrementally built collection set. 1394N/A // Initialize incremental collection set info. 1394N/A // Stop adding regions to the incremental collection set 1394N/A // for the incrementally built collection set. 1394N/A // Update information about hr in the aggregated information for 1394N/A // the incrementally built collection set. 1394N/A // Update the incremental cset information when adding a region 1394N/A // (should not be called directly). 1394N/A // Add hr to the LHS of the incremental collection set. 1394N/A // Add hr to the RHS of the incremental collection set. 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. 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. 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 // note start of mark thread 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 // Check any appropriate marked bytes info, asserting false if 342N/A // something's wrong, else returning "true". 342N/A // Print tracing information. 342N/A // Print stats on young survival ratio 342N/A // do that for any other surv rate groups 342N/A // square = square * square; 342N/A // Survivor regions policy. 342N/A // Current tenuring threshold, set to 0 if the collector reaches the 342N/A // maximum amount of suvivors regions. 545N/A // The limit on the number of regions allocated for survivors. 545N/A // The amount of survor regions after a collection. 545N/A // List of survivor regions. 342N/A // The limit on regions for a particular purpose is reached. 545N/A // Calculates survivor space parameters. 342N/A// This encapsulates a particular strategy for a g1 Collector. 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// 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// 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// 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 // 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// This should move to some place more general... 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 1879N/A#
endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP