hotspot/src/share/vm/gc/g1/g1MMUTracker.hpp
author kbarrett
Tue, 30 Aug 2016 23:48:16 -0400
changeset 40892 330a02d935ad
parent 33598 e230df0ac751
permissions -rw-r--r--
8156500: Move Reference pending list into VM to prevent deadlocks Summary: Move reference pending list and locking into VM Reviewed-by: coleenp, dholmes, dcubed, mchung, plevart Contributed-by: kim.barrett@oracle.com, per.liden@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
30576
463e71cefd8f 8078897: Clean out unused code in G1MMUTracker
sjohanss
parents: 22551
diff changeset
     2
 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5033
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5033
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5033
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30576
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1MMUTRACKER_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30576
diff changeset
    26
#define SHARE_VM_GC_G1_G1MMUTRACKER_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
31619
f27b8fcf4018 8078901: Add trace event for G1 MMU information
sjohanss
parents: 30764
diff changeset
    28
#include "gc/shared/gcId.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "utilities/debug.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
33598
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    32
// Two major user controls over G1 behavior are setting a pause time goal (MaxGCPauseMillis),
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    33
// over a time slice (GCPauseIntervalMillis). This defines the Minimum Mutator
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    34
// Utilisation (MMU) goal.
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    35
//
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    36
// * Definitions *
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    37
// Mutator Utilisation:
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    38
// - for a given time slice duration "ts",
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    39
// - mutator utilisation is the following fraction:
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    40
//     non_gc_time / ts
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    41
//
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    42
// Minimum Mutator Utilisation (MMU):
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    43
// - the worst mutator utilisation across all time slices.
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    44
//
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    45
// G1MMUTracker keeps track of the GC work and decides when it is OK to do GC work
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
// and for how long so that the MMU invariants are maintained.
33598
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    47
//
e230df0ac751 8140251: Define the G1 term MMU somewhere in the source code.
drwhite
parents: 33130
diff changeset
    48
// ***** ALL TIMES ARE IN SECS!!!!!!! *****
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
// this is the "interface"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7397
diff changeset
    50
class G1MMUTracker: public CHeapObj<mtGC> {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
protected:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
  double          _time_slice;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
  double          _max_gc_time; // this is per time slice
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
  G1MMUTracker(double time_slice, double max_gc_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 31619
diff changeset
    58
  virtual void add_pause(double start, double end) = 0;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
  virtual double when_sec(double current_time, double pause_time) = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
33130
a776072941e8 8138969: G1CollectorPolicy should use const for applicable methods
ehelin
parents: 33107
diff changeset
    61
  double max_gc_time() const {
3691
c84b8483cd2c 6871111: G1: remove the concurrent overhead tracker
tonyp
parents: 2105
diff changeset
    62
    return _max_gc_time;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
  inline bool now_max_gc(double current_time) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
    return when_sec(current_time, max_gc_time()) < 0.00001;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
  inline double when_max_gc_sec(double current_time) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
    return when_sec(current_time, max_gc_time());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
  inline jlong when_max_gc_ms(double current_time) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
    double when = when_max_gc_sec(current_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
    return (jlong) (when * 1000.0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    76
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    77
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
  inline jlong when_ms(double current_time, double pause_time) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
    double when = when_sec(current_time, pause_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    80
    return (jlong) (when * 1000.0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    82
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
2013
49e915da0905 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 1374
diff changeset
    84
class G1MMUTrackerQueueElem VALUE_OBJ_CLASS_SPEC {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
private:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
  double _start_time;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
  double _end_time;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
  inline double start_time() { return _start_time; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
  inline double end_time()   { return _end_time; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
  inline double duration()   { return _end_time - _start_time; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    93
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    94
  G1MMUTrackerQueueElem() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    95
    _start_time = 0.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
    _end_time   = 0.0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
  G1MMUTrackerQueueElem(double start_time, double end_time) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
    _start_time = start_time;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
    _end_time   = end_time;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
// this is an implementation of the MMUTracker using a (fixed-size) queue
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
// that keeps track of all the recent pause times
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
class G1MMUTrackerQueue: public G1MMUTracker {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
private:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   109
  enum PrivateConstants {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   110
    QueueLength = 64
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
  };
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   112
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   113
  // The array keeps track of all the pauses that fall within a time
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   114
  // slice (the last time slice during which pauses took place).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
  // The data structure implemented is a circular queue.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   116
  // Head "points" to the most recent addition, tail to the oldest one.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   117
  // The array is of fixed size and I don't think we'll need more than
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 13963
diff changeset
   118
  // two or three entries with the current behavior of G1 pauses.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   119
  // If the array is full, an easy fix is to look for the pauses with
4458
075a9ef4e467 6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents: 3691
diff changeset
   120
  // the shortest gap between them and consolidate them.
075a9ef4e467 6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents: 3691
diff changeset
   121
  // For now, we have taken the expedient alternative of forgetting
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4458
diff changeset
   122
  // the oldest entry in the event that +G1UseFixedWindowMMUTracker, thus
4458
075a9ef4e467 6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents: 3691
diff changeset
   123
  // potentially violating MMU specs for some time thereafter.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   124
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   125
  G1MMUTrackerQueueElem _array[QueueLength];
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   126
  int                   _head_index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   127
  int                   _tail_index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
  int                   _no_entries;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
  inline int trim_index(int index) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   131
    return (index + QueueLength) % QueueLength;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   132
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   133
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   134
  void remove_expired_entries(double current_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   135
  double calculate_gc_time(double current_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
  double when_internal(double current_time, double pause_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
  G1MMUTrackerQueue(double time_slice, double max_gc_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   141
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 31619
diff changeset
   142
  virtual void add_pause(double start, double end);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   143
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   144
  virtual double when_sec(double current_time, double pause_time);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   145
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   146
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30576
diff changeset
   147
#endif // SHARE_VM_GC_G1_G1MMUTRACKER_HPP