hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp
author tschatzl
Tue, 24 Nov 2015 10:35:52 +0100
changeset 34299 3fdfdda0ac1f
parent 34298 f3c9dcc5af96
child 34300 6075c1e0e913
permissions -rw-r--r--
8136678: Implement adaptive sizing algorithm for IHOP Summary: Add adaptive sizing for IHOP that maximizes throughput (starts marking as late as possible). This functionality is enabled using a new -XX:+G1AdaptiveIHOP switch (default: false). Reviewed-by: mgerdin, jmasa, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     1
/*
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
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/g1ErgoVerbose.hpp"
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    28
#include "gc/g1/g1IHOPControl.hpp"
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
    29
#include "gc/g1/g1Predictions.hpp"
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    30
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    31
G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    32
  _initial_ihop_percent(initial_ihop_percent),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    33
  _target_occupancy(target_occupancy),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    34
  _last_allocated_bytes(0),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    35
  _last_allocation_time_s(0.0)
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    36
{
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    37
  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
    38
}
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
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
    41
  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
    42
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    43
  _last_allocation_time_s = allocation_time_s;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    44
  _last_allocated_bytes = allocated_bytes;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    45
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    46
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    47
void G1IHOPControl::print() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    48
  size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    49
  ergo_verbose6(ErgoIHOP,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    50
                "basic information",
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    51
                ergo_format_reason("value update")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    52
                ergo_format_byte_perc("threshold")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    53
                ergo_format_byte("target occupancy")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    54
                ergo_format_byte("current occupancy")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    55
                ergo_format_double("recent old gen allocation rate")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    56
                ergo_format_double("recent marking phase length"),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    57
                cur_conc_mark_start_threshold,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    58
                cur_conc_mark_start_threshold * 100.0 / _target_occupancy,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    59
                _target_occupancy,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    60
                G1CollectedHeap::heap()->used(),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    61
                _last_allocation_time_s > 0.0 ? _last_allocated_bytes / _last_allocation_time_s : 0.0,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    62
                last_marking_length_s());
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    63
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    64
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    65
G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    66
  G1IHOPControl(ihop_percent, target_occupancy),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    67
  _last_marking_length_s(0.0) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    68
  assert(_target_occupancy > 0, "Target occupancy must be larger than zero.");
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    69
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    70
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    71
#ifndef PRODUCT
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    72
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
    73
  for (int i = 0; i < 100; i++) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    74
    ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    75
    ctrl->update_marking_length(mark_time);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    76
  }
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    77
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    78
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    79
void G1StaticIHOPControl::test() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    80
  size_t const initial_ihop = 45;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    81
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    82
  G1StaticIHOPControl ctrl(initial_ihop, 100);
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
  size_t threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    85
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    86
         "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
    87
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    88
  ctrl.update_allocation_info(100.0, 100, 100);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    89
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    90
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    91
         "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
    92
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    93
  ctrl.update_marking_length(1000.0);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    94
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    95
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    96
         "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
    97
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    98
  // Whatever we pass, the IHOP value must stay the same.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    99
  test_update(&ctrl, 2, 10, 10, 3);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   100
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   101
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   102
         "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
   103
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   104
  test_update(&ctrl, 12, 10, 10, 3);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   105
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   106
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   107
         "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
   108
}
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   109
#endif
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   110
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   111
G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   112
                                             size_t initial_target_occupancy,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   113
                                             G1Predictions const* predictor,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   114
                                             size_t heap_reserve_percent,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   115
                                             size_t heap_waste_percent) :
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   116
  G1IHOPControl(ihop_percent, initial_target_occupancy),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   117
  _predictor(predictor),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   118
  _marking_times_s(10, 0.95),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   119
  _allocation_rate_s(10, 0.95),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   120
  _last_unrestrained_young_size(0),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   121
  _heap_reserve_percent(heap_reserve_percent),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   122
  _heap_waste_percent(heap_waste_percent)
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   123
{
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
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   126
size_t G1AdaptiveIHOPControl::actual_target_threshold() const {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   127
  // 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
   128
  // free space  into account.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   129
  // _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
   130
  // eventual promotion failure.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   131
  // _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
   132
  // 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
   133
  // considered.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   134
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   135
  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
   136
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   137
  return MIN2(
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   138
    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
   139
    _target_occupancy * (100.0 - _heap_waste_percent) / 100.0
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   140
    );
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   141
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   142
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   143
bool G1AdaptiveIHOPControl::have_enough_data_for_prediction() const {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   144
  return ((size_t)_marking_times_s.num() >= G1AdaptiveIHOPNumInitialSamples) &&
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   145
         ((size_t)_allocation_rate_s.num() >= G1AdaptiveIHOPNumInitialSamples);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   146
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   147
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   148
size_t G1AdaptiveIHOPControl::get_conc_mark_start_threshold() {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   149
  if (have_enough_data_for_prediction()) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   150
    double pred_marking_time = _predictor->get_new_prediction(&_marking_times_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   151
    double pred_promotion_rate = _predictor->get_new_prediction(&_allocation_rate_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   152
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   153
    size_t predicted_needed_bytes_during_marking =
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   154
      (pred_marking_time * pred_promotion_rate +
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   155
      _last_unrestrained_young_size); // In reality we would need the maximum size of the young gen during marking. This is a conservative estimate.
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
    size_t internal_threshold = actual_target_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   158
    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
   159
                                            internal_threshold - predicted_needed_bytes_during_marking :
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   160
                                            0;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   161
    return predicted_initiating_threshold;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   162
  } else {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   163
    // Use the initial value.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   164
    return _initial_ihop_percent * _target_occupancy / 100.0;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   165
  }
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   166
}
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
void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   169
  assert(allocation_time_s >= 0.0, "Allocation time must be positive but is %.3f", allocation_time_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   170
  double allocation_rate = (double) allocated_bytes / allocation_time_s;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   171
  _allocation_rate_s.add(allocation_rate);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   172
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   173
  _last_allocation_bytes = allocated_bytes;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   174
  _last_unrestrained_young_size = additional_buffer_size;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   175
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   176
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   177
void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   178
   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
   179
  _marking_times_s.add(marking_length_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   180
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   181
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   182
void G1AdaptiveIHOPControl::print() {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   183
  ergo_verbose6(ErgoIHOP,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   184
                "basic information",
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   185
                ergo_format_reason("value update")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   186
                ergo_format_byte_perc("threshold")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   187
                ergo_format_byte("target occupancy")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   188
                ergo_format_byte("current occupancy")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   189
                ergo_format_double("recent old gen allocation rate")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   190
                ergo_format_double("recent marking phase length"),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   191
                get_conc_mark_start_threshold(),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   192
                percent_of(get_conc_mark_start_threshold(), _target_occupancy),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   193
                _target_occupancy,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   194
                G1CollectedHeap::heap()->used(),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   195
                _allocation_rate_s.last(),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   196
                _marking_times_s.last()
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   197
                );
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   198
  size_t actual_target = actual_target_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   199
  ergo_verbose6(ErgoIHOP,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   200
                "adaptive IHOP information",
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   201
                ergo_format_reason("value update")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   202
                ergo_format_byte_perc("threshold")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   203
                ergo_format_byte("internal target occupancy")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   204
                ergo_format_double("predicted old gen allocation rate")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   205
                ergo_format_double("predicted marking phase length")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   206
                ergo_format_str("prediction active"),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   207
                get_conc_mark_start_threshold(),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   208
                percent_of(get_conc_mark_start_threshold(), actual_target),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   209
                actual_target,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   210
                _predictor->get_new_prediction(&_allocation_rate_s),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   211
                _predictor->get_new_prediction(&_marking_times_s),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   212
                have_enough_data_for_prediction() ? "true" : "false"
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   213
                );
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   214
}
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
#ifndef PRODUCT
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   217
void G1AdaptiveIHOPControl::test() {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   218
  size_t const initial_threshold = 45;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   219
  size_t const young_size = 10;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   220
  size_t const target_size = 100;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   221
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   222
  // The final IHOP value is always
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   223
  // target_size - (young_size + alloc_amount/alloc_time * marking_time)
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   224
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   225
  G1Predictions pred(0.95);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   226
  G1AdaptiveIHOPControl ctrl(initial_threshold, target_size, &pred, 0, 0);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   227
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   228
  // First "load".
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   229
  size_t const alloc_time1 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   230
  size_t const alloc_amount1 = 10;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   231
  size_t const marking_time1 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   232
  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
   233
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   234
  size_t threshold;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   235
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   236
  assert(threshold == initial_threshold,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   237
         "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
   238
  for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   239
    ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   240
    ctrl.update_marking_length(marking_time1);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   241
    // Not enough data yet.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   242
    threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   243
    assert(threshold == initial_threshold,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   244
           "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
   245
  }
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
  test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   248
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   249
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   250
  assert(threshold == settled_ihop1,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   251
         "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
   252
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   253
  // Second "load". A bit higher allocation rate.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   254
  size_t const alloc_time2 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   255
  size_t const alloc_amount2 = 30;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   256
  size_t const marking_time2 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   257
  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
   258
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   259
  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   260
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   261
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   262
  assert(threshold < settled_ihop1,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   263
         "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
   264
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   265
  // Third "load". Very high (impossible) allocation rate.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   266
  size_t const alloc_time3 = 1;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   267
  size_t const alloc_amount3 = 50;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   268
  size_t const marking_time3 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   269
  size_t const settled_ihop3 = 0;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   270
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   271
  test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   272
  threshold = ctrl.get_conc_mark_start_threshold();
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
  assert(threshold == settled_ihop3,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   275
         "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
   276
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   277
  // And back to some arbitrary value.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   278
  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   279
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   280
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   281
  assert(threshold > settled_ihop3,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   282
         "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
   283
}
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   284
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   285
void IHOP_test() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   286
  G1StaticIHOPControl::test();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   287
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   288
#endif