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

Fri, 10 Oct 2014 15:51:58 +0200

author
tschatzl
date
Fri, 10 Oct 2014 15:51:58 +0200
changeset 7257
e7d0505c8a30
parent 4153
b9a9ed0f8eeb
child 6876
710a3c8b516e
permissions
-rw-r--r--

8059758: Footprint regressions with JDK-8038423
Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything.
Reviewed-by: jwilhelm, brutisso

ysr@777 1 /*
mikael@4153 2 * Copyright (c) 2001, 2012, 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
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1MMUTRACKER_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1MMUTRACKER_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
stefank@2314 29 #include "utilities/debug.hpp"
stefank@2314 30
ysr@777 31 // Keeps track of the GC work and decides when it is OK to do GC work
ysr@777 32 // and for how long so that the MMU invariants are maintained.
ysr@777 33
ysr@777 34 /***** ALL TIMES ARE IN SECS!!!!!!! *****/
ysr@777 35
ysr@777 36 // this is the "interface"
zgu@3900 37 class G1MMUTracker: public CHeapObj<mtGC> {
ysr@777 38 protected:
ysr@777 39 double _time_slice;
ysr@777 40 double _max_gc_time; // this is per time slice
ysr@777 41
ysr@777 42 public:
ysr@777 43 G1MMUTracker(double time_slice, double max_gc_time);
ysr@777 44
ysr@777 45 virtual void add_pause(double start, double end, bool gc_thread) = 0;
ysr@777 46 virtual double longest_pause(double current_time) = 0;
ysr@777 47 virtual double when_sec(double current_time, double pause_time) = 0;
ysr@777 48
ysr@777 49 double max_gc_time() {
tonyp@1371 50 return _max_gc_time;
ysr@777 51 }
ysr@777 52
ysr@777 53 inline bool now_max_gc(double current_time) {
ysr@777 54 return when_sec(current_time, max_gc_time()) < 0.00001;
ysr@777 55 }
ysr@777 56
ysr@777 57 inline double when_max_gc_sec(double current_time) {
ysr@777 58 return when_sec(current_time, max_gc_time());
ysr@777 59 }
ysr@777 60
ysr@777 61 inline jlong when_max_gc_ms(double current_time) {
ysr@777 62 double when = when_max_gc_sec(current_time);
ysr@777 63 return (jlong) (when * 1000.0);
ysr@777 64 }
ysr@777 65
ysr@777 66 inline jlong when_ms(double current_time, double pause_time) {
ysr@777 67 double when = when_sec(current_time, pause_time);
ysr@777 68 return (jlong) (when * 1000.0);
ysr@777 69 }
ysr@777 70 };
ysr@777 71
apetrusenko@984 72 class G1MMUTrackerQueueElem VALUE_OBJ_CLASS_SPEC {
ysr@777 73 private:
ysr@777 74 double _start_time;
ysr@777 75 double _end_time;
ysr@777 76
ysr@777 77 public:
ysr@777 78 inline double start_time() { return _start_time; }
ysr@777 79 inline double end_time() { return _end_time; }
ysr@777 80 inline double duration() { return _end_time - _start_time; }
ysr@777 81
ysr@777 82 G1MMUTrackerQueueElem() {
ysr@777 83 _start_time = 0.0;
ysr@777 84 _end_time = 0.0;
ysr@777 85 }
ysr@777 86
ysr@777 87 G1MMUTrackerQueueElem(double start_time, double end_time) {
ysr@777 88 _start_time = start_time;
ysr@777 89 _end_time = end_time;
ysr@777 90 }
ysr@777 91 };
ysr@777 92
ysr@777 93 // this is an implementation of the MMUTracker using a (fixed-size) queue
ysr@777 94 // that keeps track of all the recent pause times
ysr@777 95 class G1MMUTrackerQueue: public G1MMUTracker {
ysr@777 96 private:
ysr@777 97 enum PrivateConstants {
ysr@777 98 QueueLength = 64
ysr@777 99 };
ysr@777 100
ysr@777 101 // The array keeps track of all the pauses that fall within a time
ysr@777 102 // slice (the last time slice during which pauses took place).
ysr@777 103 // The data structure implemented is a circular queue.
ysr@777 104 // Head "points" to the most recent addition, tail to the oldest one.
ysr@777 105 // The array is of fixed size and I don't think we'll need more than
ysr@777 106 // two or three entries with the current behaviour of G1 pauses.
ysr@777 107 // If the array is full, an easy fix is to look for the pauses with
ysr@1523 108 // the shortest gap between them and consolidate them.
ysr@1523 109 // For now, we have taken the expedient alternative of forgetting
tonyp@1717 110 // the oldest entry in the event that +G1UseFixedWindowMMUTracker, thus
ysr@1523 111 // potentially violating MMU specs for some time thereafter.
ysr@777 112
ysr@777 113 G1MMUTrackerQueueElem _array[QueueLength];
ysr@777 114 int _head_index;
ysr@777 115 int _tail_index;
ysr@777 116 int _no_entries;
ysr@777 117
ysr@777 118 inline int trim_index(int index) {
ysr@777 119 return (index + QueueLength) % QueueLength;
ysr@777 120 }
ysr@777 121
ysr@777 122 void remove_expired_entries(double current_time);
ysr@777 123 double calculate_gc_time(double current_time);
ysr@777 124
ysr@777 125 double longest_pause_internal(double current_time);
ysr@777 126 double when_internal(double current_time, double pause_time);
ysr@777 127
ysr@777 128 public:
ysr@777 129 G1MMUTrackerQueue(double time_slice, double max_gc_time);
ysr@777 130
ysr@777 131 virtual void add_pause(double start, double end, bool gc_thread);
ysr@777 132
ysr@777 133 virtual double longest_pause(double current_time);
ysr@777 134 virtual double when_sec(double current_time, double pause_time);
ysr@777 135 };
stefank@2314 136
stefank@2314 137 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1MMUTRACKER_HPP

mercurial