src/share/vm/gc_implementation/g1/g1MMUTracker.hpp

Mon, 03 Aug 2009 12:59:30 -0700

author
johnc
date
Mon, 03 Aug 2009 12:59:30 -0700
changeset 1324
15c5903cf9e1
parent 1014
0fbdb4381b99
child 1371
e1fdf4fd34dc
permissions
-rw-r--r--

6865703: G1: Parallelize hot card cache cleanup
Summary: Have the GC worker threads clear the hot card cache in parallel by having each worker thread claim a chunk of the card cache and process the cards in that chunk. The size of the chunks that each thread will claim is determined at VM initialization from the size of the card cache and the number of worker threads.
Reviewed-by: jmasa, tonyp

ysr@777 1 /*
xdono@1014 2 * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
ysr@777 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ysr@777 20 * CA 95054 USA or visit www.sun.com if you need additional information or
ysr@777 21 * have any questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
ysr@777 25 // Keeps track of the GC work and decides when it is OK to do GC work
ysr@777 26 // and for how long so that the MMU invariants are maintained.
ysr@777 27
ysr@777 28 /***** ALL TIMES ARE IN SECS!!!!!!! *****/
ysr@777 29
ysr@777 30 // this is the "interface"
apetrusenko@984 31 class G1MMUTracker: public CHeapObj {
ysr@777 32 protected:
ysr@777 33 double _time_slice;
ysr@777 34 double _max_gc_time; // this is per time slice
ysr@777 35
ysr@777 36 double _conc_overhead_time_sec;
ysr@777 37
ysr@777 38 public:
ysr@777 39 G1MMUTracker(double time_slice, double max_gc_time);
ysr@777 40
ysr@777 41 void update_conc_overhead(double conc_overhead);
ysr@777 42
ysr@777 43 virtual void add_pause(double start, double end, bool gc_thread) = 0;
ysr@777 44 virtual double longest_pause(double current_time) = 0;
ysr@777 45 virtual double when_sec(double current_time, double pause_time) = 0;
ysr@777 46
ysr@777 47 double max_gc_time() {
ysr@777 48 return _max_gc_time - _conc_overhead_time_sec;
ysr@777 49 }
ysr@777 50
ysr@777 51 inline bool now_max_gc(double current_time) {
ysr@777 52 return when_sec(current_time, max_gc_time()) < 0.00001;
ysr@777 53 }
ysr@777 54
ysr@777 55 inline double when_max_gc_sec(double current_time) {
ysr@777 56 return when_sec(current_time, max_gc_time());
ysr@777 57 }
ysr@777 58
ysr@777 59 inline jlong when_max_gc_ms(double current_time) {
ysr@777 60 double when = when_max_gc_sec(current_time);
ysr@777 61 return (jlong) (when * 1000.0);
ysr@777 62 }
ysr@777 63
ysr@777 64 inline jlong when_ms(double current_time, double pause_time) {
ysr@777 65 double when = when_sec(current_time, pause_time);
ysr@777 66 return (jlong) (when * 1000.0);
ysr@777 67 }
ysr@777 68 };
ysr@777 69
apetrusenko@984 70 class G1MMUTrackerQueueElem VALUE_OBJ_CLASS_SPEC {
ysr@777 71 private:
ysr@777 72 double _start_time;
ysr@777 73 double _end_time;
ysr@777 74
ysr@777 75 public:
ysr@777 76 inline double start_time() { return _start_time; }
ysr@777 77 inline double end_time() { return _end_time; }
ysr@777 78 inline double duration() { return _end_time - _start_time; }
ysr@777 79
ysr@777 80 G1MMUTrackerQueueElem() {
ysr@777 81 _start_time = 0.0;
ysr@777 82 _end_time = 0.0;
ysr@777 83 }
ysr@777 84
ysr@777 85 G1MMUTrackerQueueElem(double start_time, double end_time) {
ysr@777 86 _start_time = start_time;
ysr@777 87 _end_time = end_time;
ysr@777 88 }
ysr@777 89 };
ysr@777 90
ysr@777 91 // this is an implementation of the MMUTracker using a (fixed-size) queue
ysr@777 92 // that keeps track of all the recent pause times
ysr@777 93 class G1MMUTrackerQueue: public G1MMUTracker {
ysr@777 94 private:
ysr@777 95 enum PrivateConstants {
ysr@777 96 QueueLength = 64
ysr@777 97 };
ysr@777 98
ysr@777 99 // The array keeps track of all the pauses that fall within a time
ysr@777 100 // slice (the last time slice during which pauses took place).
ysr@777 101 // The data structure implemented is a circular queue.
ysr@777 102 // Head "points" to the most recent addition, tail to the oldest one.
ysr@777 103 // The array is of fixed size and I don't think we'll need more than
ysr@777 104 // two or three entries with the current behaviour of G1 pauses.
ysr@777 105 // If the array is full, an easy fix is to look for the pauses with
ysr@777 106 // the shortest gap between them and concolidate them.
ysr@777 107
ysr@777 108 G1MMUTrackerQueueElem _array[QueueLength];
ysr@777 109 int _head_index;
ysr@777 110 int _tail_index;
ysr@777 111 int _no_entries;
ysr@777 112
ysr@777 113 inline int trim_index(int index) {
ysr@777 114 return (index + QueueLength) % QueueLength;
ysr@777 115 }
ysr@777 116
ysr@777 117 void remove_expired_entries(double current_time);
ysr@777 118 double calculate_gc_time(double current_time);
ysr@777 119
ysr@777 120 double longest_pause_internal(double current_time);
ysr@777 121 double when_internal(double current_time, double pause_time);
ysr@777 122
ysr@777 123 public:
ysr@777 124 G1MMUTrackerQueue(double time_slice, double max_gc_time);
ysr@777 125
ysr@777 126 virtual void add_pause(double start, double end, bool gc_thread);
ysr@777 127
ysr@777 128 virtual double longest_pause(double current_time);
ysr@777 129 virtual double when_sec(double current_time, double pause_time);
ysr@777 130 };

mercurial