hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp
author kbarrett
Tue, 30 Aug 2016 23:48:16 -0400
changeset 40892 330a02d935ad
parent 36577 e177c49493e9
child 41316 216f4f645fd8
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:
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     1
/*
36366
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     4
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     8
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    14
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    18
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    21
 * questions.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    22
 *
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    23
 */
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    24
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    25
#include "precompiled.hpp"
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    26
#include "gc/g1/g1CollectedHeap.inline.hpp"
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    27
#include "gc/g1/g1IHOPControl.hpp"
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
    28
#include "gc/g1/g1Predictions.hpp"
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    29
#include "gc/shared/gcTrace.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
    30
#include "logging/log.hpp"
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    31
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    32
G1IHOPControl::G1IHOPControl(double initial_ihop_percent) :
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    33
  _initial_ihop_percent(initial_ihop_percent),
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    34
  _target_occupancy(0),
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    35
  _last_allocated_bytes(0),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    36
  _last_allocation_time_s(0.0)
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    37
{
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    38
  assert(_initial_ihop_percent >= 0.0 && _initial_ihop_percent <= 100.0, "Initial IHOP value must be between 0 and 100 but is %.3f", initial_ihop_percent);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    39
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    40
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    41
void G1IHOPControl::update_target_occupancy(size_t new_target_occupancy) {
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    42
  log_debug(gc, ihop)("Target occupancy update: old: " SIZE_FORMAT "B, new: " SIZE_FORMAT "B",
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    43
                      _target_occupancy, new_target_occupancy);
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    44
  _target_occupancy = new_target_occupancy;
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    45
}
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    46
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    47
void G1IHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    48
  assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    49
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    50
  _last_allocation_time_s = allocation_time_s;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    51
  _last_allocated_bytes = allocated_bytes;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    52
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    53
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    54
void G1IHOPControl::print() {
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    55
  assert(_target_occupancy > 0, "Target occupancy still not updated yet.");
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    56
  size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold();
36366
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
    57
  log_debug(gc, ihop)("Basic information (value update), threshold: " SIZE_FORMAT "B (%1.2f), target occupancy: " SIZE_FORMAT "B, current occupancy: " SIZE_FORMAT "B, "
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
    58
                      "recent allocation size: " SIZE_FORMAT "B, recent allocation duration: %1.2fms, recent old gen allocation rate: %1.2fB/s, recent marking phase length: %1.2fms",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
    59
                      cur_conc_mark_start_threshold,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
    60
                      cur_conc_mark_start_threshold * 100.0 / _target_occupancy,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
    61
                      _target_occupancy,
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
    62
                      G1CollectedHeap::heap()->used(),
36366
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
    63
                      _last_allocated_bytes,
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
    64
                      _last_allocation_time_s * 1000.0,
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
    65
                      _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
36366
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
    66
                      last_marking_length_s() * 1000.0);
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    67
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    68
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    69
void G1IHOPControl::send_trace_event(G1NewTracer* tracer) {
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    70
  assert(_target_occupancy > 0, "Target occupancy still not updated yet.");
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    71
  tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    72
                                       _target_occupancy,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    73
                                       G1CollectedHeap::heap()->used(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    74
                                       _last_allocated_bytes,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    75
                                       _last_allocation_time_s,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    76
                                       last_marking_length_s());
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    77
}
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    78
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    79
G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent) :
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    80
  G1IHOPControl(ihop_percent),
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    81
  _last_marking_length_s(0.0) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    82
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    83
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    84
#ifndef PRODUCT
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    85
static void test_update(G1IHOPControl* ctrl, double alloc_time, size_t alloc_amount, size_t young_size, double mark_time) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    86
  for (int i = 0; i < 100; i++) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    87
    ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    88
    ctrl->update_marking_length(mark_time);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    89
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    90
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    91
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    92
void G1StaticIHOPControl::test() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    93
  size_t const initial_ihop = 45;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    94
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    95
  G1StaticIHOPControl ctrl(initial_ihop);
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
    96
  ctrl.update_target_occupancy(100);
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    97
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    98
  size_t threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    99
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   100
         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   101
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   102
  ctrl.update_allocation_info(100.0, 100, 100);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   103
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   104
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   105
         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   106
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   107
  ctrl.update_marking_length(1000.0);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   108
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   109
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   110
         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   111
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   112
  // Whatever we pass, the IHOP value must stay the same.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   113
  test_update(&ctrl, 2, 10, 10, 3);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   114
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   115
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   116
         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   117
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   118
  test_update(&ctrl, 12, 10, 10, 3);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   119
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   120
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   121
         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_ihop, threshold);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   122
}
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   123
#endif
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   124
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   125
G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   126
                                             G1Predictions const* predictor,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   127
                                             size_t heap_reserve_percent,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   128
                                             size_t heap_waste_percent) :
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
   129
  G1IHOPControl(ihop_percent),
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   130
  _predictor(predictor),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   131
  _marking_times_s(10, 0.95),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   132
  _allocation_rate_s(10, 0.95),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   133
  _last_unrestrained_young_size(0),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   134
  _heap_reserve_percent(heap_reserve_percent),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   135
  _heap_waste_percent(heap_waste_percent)
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   136
{
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   137
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   138
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   139
size_t G1AdaptiveIHOPControl::actual_target_threshold() const {
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
   140
  guarantee(_target_occupancy > 0, "Target occupancy still not updated yet.");
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   141
  // The actual target threshold takes the heap reserve and the expected waste in
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   142
  // free space  into account.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   143
  // _heap_reserve is that part of the total heap capacity that is reserved for
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   144
  // eventual promotion failure.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   145
  // _heap_waste is the amount of space will never be reclaimed in any
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   146
  // heap, so can not be used for allocation during marking and must always be
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   147
  // considered.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   148
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   149
  double safe_total_heap_percentage = MIN2((double)(_heap_reserve_percent + _heap_waste_percent), 100.0);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   150
35196
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   151
  return (size_t)MIN2(
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   152
    G1CollectedHeap::heap()->max_capacity() * (100.0 - safe_total_heap_percentage) / 100.0,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   153
    _target_occupancy * (100.0 - _heap_waste_percent) / 100.0
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   154
    );
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   155
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   156
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   157
bool G1AdaptiveIHOPControl::have_enough_data_for_prediction() const {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   158
  return ((size_t)_marking_times_s.num() >= G1AdaptiveIHOPNumInitialSamples) &&
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   159
         ((size_t)_allocation_rate_s.num() >= G1AdaptiveIHOPNumInitialSamples);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   160
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   161
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   162
size_t G1AdaptiveIHOPControl::get_conc_mark_start_threshold() {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   163
  if (have_enough_data_for_prediction()) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   164
    double pred_marking_time = _predictor->get_new_prediction(&_marking_times_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   165
    double pred_promotion_rate = _predictor->get_new_prediction(&_allocation_rate_s);
35196
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   166
    size_t pred_promotion_size = (size_t)(pred_marking_time * pred_promotion_rate);
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   167
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   168
    size_t predicted_needed_bytes_during_marking =
35196
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   169
      pred_promotion_size +
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   170
      // In reality we would need the maximum size of the young gen during
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   171
      // marking. This is a conservative estimate.
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   172
      _last_unrestrained_young_size;
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   173
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   174
    size_t internal_threshold = actual_target_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   175
    size_t predicted_initiating_threshold = predicted_needed_bytes_during_marking < internal_threshold ?
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   176
                                            internal_threshold - predicted_needed_bytes_during_marking :
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   177
                                            0;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   178
    return predicted_initiating_threshold;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   179
  } else {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   180
    // Use the initial value.
35196
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   181
    return (size_t)(_initial_ihop_percent * _target_occupancy / 100.0);
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   182
  }
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   183
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   184
35196
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   185
void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s,
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   186
                                                   size_t allocated_bytes,
c83940b346b2 8143215: gcc 4.1.2: fix three issues breaking the build.
goetz
parents: 35061
diff changeset
   187
                                                   size_t additional_buffer_size) {
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   188
  G1IHOPControl::update_allocation_info(allocation_time_s, allocated_bytes, additional_buffer_size);
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   189
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   190
  double allocation_rate = (double) allocated_bytes / allocation_time_s;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   191
  _allocation_rate_s.add(allocation_rate);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   192
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   193
  _last_unrestrained_young_size = additional_buffer_size;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   194
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   195
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   196
void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   197
   assert(marking_length_s >= 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   198
  _marking_times_s.add(marking_length_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   199
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   200
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   201
void G1AdaptiveIHOPControl::print() {
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   202
  G1IHOPControl::print();
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   203
  size_t actual_target = actual_target_threshold();
36366
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
   204
  log_debug(gc, ihop)("Adaptive IHOP information (value update), threshold: " SIZE_FORMAT "B (%1.2f), internal target occupancy: " SIZE_FORMAT "B, "
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
   205
                      "occupancy: " SIZE_FORMAT "B, additional buffer size: " SIZE_FORMAT "B, predicted old gen allocation rate: %1.2fB/s, "
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
   206
                      "predicted marking phase length: %1.2fms, prediction active: %s",
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
   207
                      get_conc_mark_start_threshold(),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
   208
                      percent_of(get_conc_mark_start_threshold(), actual_target),
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
   209
                      actual_target,
36366
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
   210
                      G1CollectedHeap::heap()->used(),
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
   211
                      _last_unrestrained_young_size,
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
   212
                      _predictor->get_new_prediction(&_allocation_rate_s),
36366
664ae1e77870 8140777: Make Adaptive IHOP logging information the same as JFR logging
tschatzl
parents: 35196
diff changeset
   213
                      _predictor->get_new_prediction(&_marking_times_s) * 1000.0,
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 34300
diff changeset
   214
                      have_enough_data_for_prediction() ? "true" : "false");
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   215
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   216
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   217
void G1AdaptiveIHOPControl::send_trace_event(G1NewTracer* tracer) {
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   218
  G1IHOPControl::send_trace_event(tracer);
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   219
  tracer->report_adaptive_ihop_statistics(get_conc_mark_start_threshold(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   220
                                          actual_target_threshold(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   221
                                          G1CollectedHeap::heap()->used(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   222
                                          _last_unrestrained_young_size,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   223
                                          _predictor->get_new_prediction(&_allocation_rate_s),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   224
                                          _predictor->get_new_prediction(&_marking_times_s),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   225
                                          have_enough_data_for_prediction());
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   226
}
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   227
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   228
#ifndef PRODUCT
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   229
void G1AdaptiveIHOPControl::test() {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   230
  size_t const initial_threshold = 45;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   231
  size_t const young_size = 10;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   232
  size_t const target_size = 100;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   233
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   234
  // The final IHOP value is always
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   235
  // target_size - (young_size + alloc_amount/alloc_time * marking_time)
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   236
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   237
  G1Predictions pred(0.95);
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
   238
  G1AdaptiveIHOPControl ctrl(initial_threshold, &pred, 0, 0);
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
   239
  ctrl.update_target_occupancy(target_size);
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   240
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   241
  // First "load".
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   242
  size_t const alloc_time1 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   243
  size_t const alloc_amount1 = 10;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   244
  size_t const marking_time1 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   245
  size_t const settled_ihop1 = target_size - (young_size + alloc_amount1/alloc_time1 * marking_time1);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   246
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   247
  size_t threshold;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   248
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   249
  assert(threshold == initial_threshold,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   250
         "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   251
  for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   252
    ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   253
    ctrl.update_marking_length(marking_time1);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   254
    // Not enough data yet.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   255
    threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   256
    assert(threshold == initial_threshold,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   257
           "Expected IHOP threshold of " SIZE_FORMAT " but is " SIZE_FORMAT, initial_threshold, threshold);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   258
  }
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   259
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   260
  test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   261
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   262
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   263
  assert(threshold == settled_ihop1,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   264
         "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   265
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   266
  // Second "load". A bit higher allocation rate.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   267
  size_t const alloc_time2 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   268
  size_t const alloc_amount2 = 30;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   269
  size_t const marking_time2 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   270
  size_t const settled_ihop2 = target_size - (young_size + alloc_amount2/alloc_time2 * marking_time2);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   271
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   272
  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   273
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   274
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   275
  assert(threshold < settled_ihop1,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   276
         "Expected IHOP threshold to settle at a value lower than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop1, threshold);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   277
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   278
  // Third "load". Very high (impossible) allocation rate.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   279
  size_t const alloc_time3 = 1;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   280
  size_t const alloc_amount3 = 50;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   281
  size_t const marking_time3 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   282
  size_t const settled_ihop3 = 0;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   283
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   284
  test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   285
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   286
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   287
  assert(threshold == settled_ihop3,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   288
         "Expected IHOP threshold to settle at " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   289
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   290
  // And back to some arbitrary value.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   291
  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   292
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   293
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   294
  assert(threshold > settled_ihop3,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   295
         "Expected IHOP threshold to settle at value larger than " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   296
}
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   297
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   298
void IHOP_test() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   299
  G1StaticIHOPControl::test();
36577
e177c49493e9 8142484: Let IHOP follow the current capacity, not the maximum capacity
tschatzl
parents: 36366
diff changeset
   300
  G1AdaptiveIHOPControl::test();
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   301
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   302
#endif