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

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1717
b81f3572f355
child 2314
f95d63e2154a
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

ysr@777 1 /*
trims@1907 2 * Copyright (c) 2001, 2009, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * 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 public:
ysr@777 37 G1MMUTracker(double time_slice, double max_gc_time);
ysr@777 38
ysr@777 39 virtual void add_pause(double start, double end, bool gc_thread) = 0;
ysr@777 40 virtual double longest_pause(double current_time) = 0;
ysr@777 41 virtual double when_sec(double current_time, double pause_time) = 0;
ysr@777 42
ysr@777 43 double max_gc_time() {
tonyp@1371 44 return _max_gc_time;
ysr@777 45 }
ysr@777 46
ysr@777 47 inline bool now_max_gc(double current_time) {
ysr@777 48 return when_sec(current_time, max_gc_time()) < 0.00001;
ysr@777 49 }
ysr@777 50
ysr@777 51 inline double when_max_gc_sec(double current_time) {
ysr@777 52 return when_sec(current_time, max_gc_time());
ysr@777 53 }
ysr@777 54
ysr@777 55 inline jlong when_max_gc_ms(double current_time) {
ysr@777 56 double when = when_max_gc_sec(current_time);
ysr@777 57 return (jlong) (when * 1000.0);
ysr@777 58 }
ysr@777 59
ysr@777 60 inline jlong when_ms(double current_time, double pause_time) {
ysr@777 61 double when = when_sec(current_time, pause_time);
ysr@777 62 return (jlong) (when * 1000.0);
ysr@777 63 }
ysr@777 64 };
ysr@777 65
apetrusenko@984 66 class G1MMUTrackerQueueElem VALUE_OBJ_CLASS_SPEC {
ysr@777 67 private:
ysr@777 68 double _start_time;
ysr@777 69 double _end_time;
ysr@777 70
ysr@777 71 public:
ysr@777 72 inline double start_time() { return _start_time; }
ysr@777 73 inline double end_time() { return _end_time; }
ysr@777 74 inline double duration() { return _end_time - _start_time; }
ysr@777 75
ysr@777 76 G1MMUTrackerQueueElem() {
ysr@777 77 _start_time = 0.0;
ysr@777 78 _end_time = 0.0;
ysr@777 79 }
ysr@777 80
ysr@777 81 G1MMUTrackerQueueElem(double start_time, double end_time) {
ysr@777 82 _start_time = start_time;
ysr@777 83 _end_time = end_time;
ysr@777 84 }
ysr@777 85 };
ysr@777 86
ysr@777 87 // this is an implementation of the MMUTracker using a (fixed-size) queue
ysr@777 88 // that keeps track of all the recent pause times
ysr@777 89 class G1MMUTrackerQueue: public G1MMUTracker {
ysr@777 90 private:
ysr@777 91 enum PrivateConstants {
ysr@777 92 QueueLength = 64
ysr@777 93 };
ysr@777 94
ysr@777 95 // The array keeps track of all the pauses that fall within a time
ysr@777 96 // slice (the last time slice during which pauses took place).
ysr@777 97 // The data structure implemented is a circular queue.
ysr@777 98 // Head "points" to the most recent addition, tail to the oldest one.
ysr@777 99 // The array is of fixed size and I don't think we'll need more than
ysr@777 100 // two or three entries with the current behaviour of G1 pauses.
ysr@777 101 // If the array is full, an easy fix is to look for the pauses with
ysr@1523 102 // the shortest gap between them and consolidate them.
ysr@1523 103 // For now, we have taken the expedient alternative of forgetting
tonyp@1717 104 // the oldest entry in the event that +G1UseFixedWindowMMUTracker, thus
ysr@1523 105 // potentially violating MMU specs for some time thereafter.
ysr@777 106
ysr@777 107 G1MMUTrackerQueueElem _array[QueueLength];
ysr@777 108 int _head_index;
ysr@777 109 int _tail_index;
ysr@777 110 int _no_entries;
ysr@777 111
ysr@777 112 inline int trim_index(int index) {
ysr@777 113 return (index + QueueLength) % QueueLength;
ysr@777 114 }
ysr@777 115
ysr@777 116 void remove_expired_entries(double current_time);
ysr@777 117 double calculate_gc_time(double current_time);
ysr@777 118
ysr@777 119 double longest_pause_internal(double current_time);
ysr@777 120 double when_internal(double current_time, double pause_time);
ysr@777 121
ysr@777 122 public:
ysr@777 123 G1MMUTrackerQueue(double time_slice, double max_gc_time);
ysr@777 124
ysr@777 125 virtual void add_pause(double start, double end, bool gc_thread);
ysr@777 126
ysr@777 127 virtual double longest_pause(double current_time);
ysr@777 128 virtual double when_sec(double current_time, double pause_time);
ysr@777 129 };

mercurial