g1CollectorPolicy.hpp revision 2754
0N/A * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// A G1CollectorPolicy makes policy decisions that determine the 0N/A// characteristics of the collector. Examples include: 0N/A// * choice of collection set. 0N/A// * when to collect. 0N/A// Yes, this is a bit unpleasant... but it saves replicating the same thing 0N/A// over and over again and introducing subtle problems through small typos and 0N/A// cutting and pasting mistakes. The macros below introduces a number 0N/A// sequnce into the following two classes and the methods that access it. 0N/A // The number of pauses during the execution. 0N/A // either equal to the number of parallel threads, if ParallelGCThreads 0N/A // has been set, or 1 otherwise 0N/A // Pick some reasonable default. 0N/A // Card Table Count Cache stats 0N/A // Statistics for recent GC pauses. See below for how indexed. 0N/A // These exclude marking times. 0N/A // indicates whether we are in full young or partially young GC mode 0N/A // if true, then it tries to dynamically adjust the length of the 0N/A // The max number of regions we can extend the eden by while the GC 0N/A // locker is active. This should be >= _young_list_target_length; 0N/A // add here any more surv rate groups 0N/A // A function that prevents us putting too much stock in small sample 0N/A // sets. Returns a number between 2.0 and 1.0, depending on the number 0N/A // of samples. 5 or more samples yields one; fewer scales linearly from 0N/A // 2.0 at 1 sample to 1.0 at 5. // also call it on any more surv rate groups // Returns an estimate of the survival rate of the region at yg-age // Used to count used bytes in CS. // Statistics kept per GC stoppage, pause or full. // Add a new GC of the given duration and end time to the record. // The head of the list (via "next_in_collection_set()") representing the // current collection set. Set from the incrementally built collection // set at the start of the pause. // The number of regions in the collection set. Set from the incrementally // built collection set at the start of an evacuation pause. // The number of bytes in the collection set before the pause. Set from // the incrementally built collection set at the start of an evacuation // The associated information that is maintained while the incremental // collection set is being built with young regions. Used to populate // the recorded info for the evacuation pause. Active,
// We are actively building the collection set Inactive // We are not actively building the collection set // The head of the incrementally built collection set. // The tail of the incrementally built collection set. // The number of regions in the incrementally built collection set. // Used to set _collection_set_size at the start of an evacuation // Used as the index in the surving young words structure // which tracks the amount of space, for each young region, // that survives the pause. // The number of bytes in the incrementally built collection set. // Used to set _collection_set_bytes_used_before at the start of // Used to record the highest end of heap region in collection set // The number of recorded used bytes in the young regions // of the collection set. This is the sum of the used() bytes // of retired young regions in the collection set. // The RSet lengths recorded for regions in the collection set // (updated by the periodic sampling of the regions in the // The predicted elapsed time it will take to collect the regions // in the collection set (updated by the periodic sampling of the // The predicted bytes to copy for the regions in the collection // set (updated by the periodic sampling of the regions in the int _n_marks;
// Sticky at 2, so we know when we've done at least 2. // The number of collection pauses at the end of the last mark. // Stash a pointer to the g1 heap. // The average time in ms per collection pause, averaged over recent pauses. // The average time in ms for RS scanning, per pause, averaged // over recent pauses. (Note the RS scanning time for a pause // is itself an average of the RS scanning time for each worker // The number of "recent" GCs recorded in the number sequences // The average survival ratio, computed by the total number of bytes // suriviving / total number of bytes before collection over the last // several recent pauses. // The survival fraction of the most recent pause; if there have been no // Returns a "conservative" estimate of the recent survival rate, i.e., // one that may be higher than "recent_avg_survival_fraction". // This is conservative in several ways: // If there have been few pauses, it will assume a potential high // variance, and err on the side of caution. // It puts a lower bound (currently 0.1) on the value it will return. // To try to detect phase changes, if the most recent pause ("latest") has a // higher-than average ("avg") survival rate, it returns that rate. // "work" version is a utility function; young is restricted to young regions. // The arguments are the two sequences that keep track of the number of bytes // surviving and the total number of bytes before collection, resp., // over the last evereal recent pauses // Returns the survival rate for the category in the most recent pause. // If there have been no pauses, returns 1.0. // The arguments are the two sequences that keep track of the number of bytes // surviving and the total number of bytes before collection, resp., // over the last several recent pauses // Returns the average survival ration over the last several recent pauses // If there have been no pauses, return 1.0 // The ratio of gc time to elapsed time, computed over recent pauses. // Number of pauses between concurrent marking. // At the end of a pause we check the heap occupancy and we decide // whether we will start a marking cycle during the next pause. If // we decide that we want to do that, we will set this parameter to // true. So, this parameter will stay true between the end of a // pause and the beginning of a subsequent pause (not necessarily // the next one, see the comments on the next field) when we decide // that we will indeed start a marking cycle and do the initial-mark // If initiate_conc_mark_if_possible() is set at the beginning of a // pause, it is a suggestion that the pause should start a marking // cycle by doing the initial-mark work. However, it is possible // that the concurrent marking thread is still finishing up the // previous marking cycle (e.g., clearing the next marking // bitmap). If that is the case we cannot start a new cycle and // we'll have to wait for the concurrent marking thread to finish // what it is doing. In this case we will postpone the marking cycle // initiation decision for the next pause. When we eventually decide // to start a cycle, we will set _during_initial_mark_pause which // will stay true until the end of the initial-mark pause and it's // the condition that indicates that a pause is doing the // This set of variables tracks the collector efficiency, in order to // determine whether we should initiate a new marking. // Update the young list target length either by setting it to the // desired fixed value or by calculating it using G1's pause // prediction model. If no rs_lengths parameter is passed, predict // the RS lengths using the prediction model, otherwise use the // given rs_lengths as the prediction. // Calculate and return the minimum desired young list target // length. This is the minimum desired young list length according // Calculate and return the maximum desired young list target // length. This is the maximum desired young list length according // Calculate and return the maximum young list target length that // can fit into the pause time goal. The parameters are: rs_lengths // represent the prediction of how large the young RSet lengths will // be, base_min_length is the alreay existing number of regions in // the young list, min_length and max_length are the desired min and // max young list length according to the user's inputs. // Check whether a given young length (young_length) fits into the // given target pause time and whether the prediction for the amount // of objects to be copied for the given length will fit into the // given free space (expressed by base_free_regions). It is used by // calculate_young_list_target_length(). // Check the current value of the young list RSet lengths and // compare it against the last prediction. If the current value is // higher, recalculate the young list target length prediction. // This should be called after the heap is resized. // Count the number of bytes used in the CS. // Together these do the base cleanup-recording work. Subclasses might // want to put something between them. // Create jstat counters for the policy. // This method controls how a collector handles one or more // of its generations being fully allocated. // The number of collection pauses so far. // Update the heuristic info to record a collection pause of the given // start time, where the given number of bytes were used at the start. // This may involve changing the desired size of a collection set. // Must currently be called while the world is stopped. // Record the fact that a full collection occurred. // Record how much space we copied during a GC. This is typically // called when a GC alloc region is being retired. // The amount of space we copied during a GC. // Choose a new collection set. Marks the chosen regions as being // "in_collection_set", and links them together. The head and number of // the collection set are available via access methods. // The head of the list (via "next_in_collection_set()") representing the // current collection set. // The number of elements in the current collection set. // Incremental CSet Support // The head of the incrementally built collection set. // The tail of the incrementally built collection set. // The number of elements in the incrementally built collection set. // Initialize incremental collection set info. // Stop adding regions to the incremental collection set // Add/remove information about hr to the aggregated information // for the incrementally built collection set. // Update information about hr in the aggregated information for // the incrementally built collection set. // Update the incremental cset information when adding a region // (should not be called directly). // Add hr to the LHS of the incremental collection set. // Add hr to the RHS of the incremental collection set. // This sets the initiate_conc_mark_if_possible() flag to start a // new cycle, as long as we are not already in one. It's best if it // is called during a safepoint when the test whether a cycle is in // progress or not is stable. // This is called at the very beginning of an evacuation pause (it // has to be the first thing that the pause does). If // initiate_conc_mark_if_possible() is true, and the concurrent // marking thread has completed its work during the previous cycle, // it will set during_initial_mark_pause() to so that the pause does // the initial-mark work and start a marking cycle. // If an expansion would be appropriate, because recent GC overhead had // exceeded the desired limit, return an amount to expand by. // note start of mark thread // The marked bytes of the "r" has changed; reclassify it's desirability // for marking. Also asserts that "r" is eligible for a CS. // Check any appropriate marked bytes info, asserting false if // something's wrong, else returning "true". // Print tracing information. // Print stats on young survival ratio // do that for any other surv rate groups // square = square * square; // Survivor regions policy. // Current tenuring threshold, set to 0 if the collector reaches the // maximum amount of suvivors regions. // The limit on the number of regions allocated for survivors. // For reporting purposes. // The amount of survor regions after a collection. // List of survivor regions. // The limit on regions for a particular purpose is reached. // Calculates survivor space parameters. // This encapsulates a particular strategy for a g1 Collector. // Start a concurrent mark when our heap size is n bytes // greater then our heap size was at the last concurrent // mark. Where n is a function of the CMSTriggerRatio // and the MinHeapFreeRatio. // Start a g1 collection pause when we have allocated the // average number of bytes currently being freed in // a collection, but only if it is at least one region // Resize Heap based on desired // allocation space, where desired allocation space is // a function of survival rate and desired future to size. // Choose collection set by first picking all older regions // which have a survival rate which beats our projected young // survival rate. Then fill out the number of needed regions // This is not needed any more, after the CSet choosing code was // changed to use the pause prediction work. But let's leave the // This should move to some place more general... // If we have "n" measurements, and we've kept track of their "sum" and the // "sum_of_squares" of the measurements, this returns the variance of the #
endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTORPOLICY_HPP