hotspot/src/share/vm/gc/g1/g1IHOPControl.cpp
author jprovino
Thu, 10 Dec 2015 23:02:31 +0000 (2015-12-10)
changeset 35060 382d0689141c
parent 34300 6075c1e0e913
child 35061 be6025ebffea
permissions -rw-r--r--
Merge
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"
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    30
#include "gc/shared/gcTrace.hpp"
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    31
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    32
G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) :
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    33
  _initial_ihop_percent(initial_ihop_percent),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    34
  _target_occupancy(target_occupancy),
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
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    41
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
    42
  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
    43
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    44
  _last_allocation_time_s = allocation_time_s;
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    45
  _last_allocated_bytes = allocated_bytes;
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
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    48
void G1IHOPControl::print() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    49
  size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    50
  ergo_verbose6(ErgoIHOP,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    51
                "basic information",
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    52
                ergo_format_reason("value update")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    53
                ergo_format_byte_perc("threshold")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    54
                ergo_format_byte("target occupancy")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    55
                ergo_format_byte("current occupancy")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    56
                ergo_format_double("recent old gen allocation rate")
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    57
                ergo_format_double("recent marking phase length"),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    58
                cur_conc_mark_start_threshold,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    59
                cur_conc_mark_start_threshold * 100.0 / _target_occupancy,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    60
                _target_occupancy,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    61
                G1CollectedHeap::heap()->used(),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    62
                _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
    63
                last_marking_length_s());
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
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    66
void G1IHOPControl::send_trace_event(G1NewTracer* tracer) {
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    67
  tracer->report_basic_ihop_statistics(get_conc_mark_start_threshold(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    68
                                       _target_occupancy,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    69
                                       G1CollectedHeap::heap()->used(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    70
                                       _last_allocated_bytes,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    71
                                       _last_allocation_time_s,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    72
                                       last_marking_length_s());
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    73
}
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
    74
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    75
G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) :
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    76
  G1IHOPControl(ihop_percent, target_occupancy),
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    77
  _last_marking_length_s(0.0) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    78
  assert(_target_occupancy > 0, "Target occupancy must be larger than zero.");
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    79
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    80
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    81
#ifndef PRODUCT
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    82
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
    83
  for (int i = 0; i < 100; i++) {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    84
    ctrl->update_allocation_info(alloc_time, alloc_amount, young_size);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    85
    ctrl->update_marking_length(mark_time);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    86
  }
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
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    89
void G1StaticIHOPControl::test() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    90
  size_t const initial_ihop = 45;
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
  G1StaticIHOPControl ctrl(initial_ihop, 100);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    93
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    94
  size_t 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
  ctrl.update_allocation_info(100.0, 100, 100);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
    99
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   100
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   101
         "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
   102
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   103
  ctrl.update_marking_length(1000.0);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   104
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   105
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   106
         "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
   107
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   108
  // Whatever we pass, the IHOP value must stay the same.
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   109
  test_update(&ctrl, 2, 10, 10, 3);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   110
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   111
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   112
         "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
   113
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   114
  test_update(&ctrl, 12, 10, 10, 3);
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   115
  threshold = ctrl.get_conc_mark_start_threshold();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   116
  assert(threshold == initial_ihop,
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   117
         "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
   118
}
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   119
#endif
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   120
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   121
G1AdaptiveIHOPControl::G1AdaptiveIHOPControl(double ihop_percent,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   122
                                             size_t initial_target_occupancy,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   123
                                             G1Predictions const* predictor,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   124
                                             size_t heap_reserve_percent,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   125
                                             size_t heap_waste_percent) :
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   126
  G1IHOPControl(ihop_percent, initial_target_occupancy),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   127
  _predictor(predictor),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   128
  _marking_times_s(10, 0.95),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   129
  _allocation_rate_s(10, 0.95),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   130
  _last_unrestrained_young_size(0),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   131
  _heap_reserve_percent(heap_reserve_percent),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   132
  _heap_waste_percent(heap_waste_percent)
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   133
{
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
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   136
size_t G1AdaptiveIHOPControl::actual_target_threshold() const {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   137
  // 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
   138
  // free space  into account.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   139
  // _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
   140
  // eventual promotion failure.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   141
  // _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
   142
  // 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
   143
  // considered.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   144
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   145
  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
   146
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   147
  return MIN2(
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   148
    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
   149
    _target_occupancy * (100.0 - _heap_waste_percent) / 100.0
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   150
    );
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   151
}
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
bool G1AdaptiveIHOPControl::have_enough_data_for_prediction() const {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   154
  return ((size_t)_marking_times_s.num() >= G1AdaptiveIHOPNumInitialSamples) &&
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   155
         ((size_t)_allocation_rate_s.num() >= G1AdaptiveIHOPNumInitialSamples);
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
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   158
size_t G1AdaptiveIHOPControl::get_conc_mark_start_threshold() {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   159
  if (have_enough_data_for_prediction()) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   160
    double pred_marking_time = _predictor->get_new_prediction(&_marking_times_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   161
    double pred_promotion_rate = _predictor->get_new_prediction(&_allocation_rate_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   162
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   163
    size_t predicted_needed_bytes_during_marking =
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   164
      (pred_marking_time * pred_promotion_rate +
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   165
      _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
   166
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   167
    size_t internal_threshold = actual_target_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   168
    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
   169
                                            internal_threshold - predicted_needed_bytes_during_marking :
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   170
                                            0;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   171
    return predicted_initiating_threshold;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   172
  } else {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   173
    // Use the initial value.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   174
    return _initial_ihop_percent * _target_occupancy / 100.0;
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
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   178
void G1AdaptiveIHOPControl::update_allocation_info(double allocation_time_s, size_t allocated_bytes, size_t additional_buffer_size) {
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   179
  G1IHOPControl::update_allocation_info(allocation_time_s, allocated_bytes, additional_buffer_size);
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   180
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   181
  double allocation_rate = (double) allocated_bytes / allocation_time_s;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   182
  _allocation_rate_s.add(allocation_rate);
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
  _last_unrestrained_young_size = additional_buffer_size;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   185
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   186
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   187
void G1AdaptiveIHOPControl::update_marking_length(double marking_length_s) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   188
   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
   189
  _marking_times_s.add(marking_length_s);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   190
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   191
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   192
void G1AdaptiveIHOPControl::print() {
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   193
  G1IHOPControl::print();
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   194
  size_t actual_target = actual_target_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   195
  ergo_verbose6(ErgoIHOP,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   196
                "adaptive IHOP information",
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   197
                ergo_format_reason("value update")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   198
                ergo_format_byte_perc("threshold")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   199
                ergo_format_byte("internal target occupancy")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   200
                ergo_format_double("predicted old gen allocation rate")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   201
                ergo_format_double("predicted marking phase length")
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   202
                ergo_format_str("prediction active"),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   203
                get_conc_mark_start_threshold(),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   204
                percent_of(get_conc_mark_start_threshold(), actual_target),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   205
                actual_target,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   206
                _predictor->get_new_prediction(&_allocation_rate_s),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   207
                _predictor->get_new_prediction(&_marking_times_s),
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   208
                have_enough_data_for_prediction() ? "true" : "false"
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   209
                );
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   210
}
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   211
34300
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   212
void G1AdaptiveIHOPControl::send_trace_event(G1NewTracer* tracer) {
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   213
  G1IHOPControl::send_trace_event(tracer);
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   214
  tracer->report_adaptive_ihop_statistics(get_conc_mark_start_threshold(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   215
                                          actual_target_threshold(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   216
                                          G1CollectedHeap::heap()->used(),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   217
                                          _last_unrestrained_young_size,
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   218
                                          _predictor->get_new_prediction(&_allocation_rate_s),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   219
                                          _predictor->get_new_prediction(&_marking_times_s),
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   220
                                          have_enough_data_for_prediction());
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   221
}
6075c1e0e913 8136679: JFR event for adaptive IHOP
tschatzl
parents: 34299
diff changeset
   222
34299
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   223
#ifndef PRODUCT
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   224
void G1AdaptiveIHOPControl::test() {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   225
  size_t const initial_threshold = 45;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   226
  size_t const young_size = 10;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   227
  size_t const target_size = 100;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   228
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   229
  // The final IHOP value is always
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   230
  // target_size - (young_size + alloc_amount/alloc_time * marking_time)
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   231
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   232
  G1Predictions pred(0.95);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   233
  G1AdaptiveIHOPControl ctrl(initial_threshold, target_size, &pred, 0, 0);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   234
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   235
  // First "load".
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   236
  size_t const alloc_time1 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   237
  size_t const alloc_amount1 = 10;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   238
  size_t const marking_time1 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   239
  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
   240
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   241
  size_t threshold;
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
  for (size_t i = 0; i < G1AdaptiveIHOPNumInitialSamples - 1; i++) {
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   246
    ctrl.update_allocation_info(alloc_time1, alloc_amount1, young_size);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   247
    ctrl.update_marking_length(marking_time1);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   248
    // Not enough data yet.
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 == initial_threshold,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   251
           "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
   252
  }
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   253
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   254
  test_update(&ctrl, alloc_time1, alloc_amount1, young_size, marking_time1);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   255
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   256
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   257
  assert(threshold == settled_ihop1,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   258
         "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
   259
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   260
  // Second "load". A bit higher allocation rate.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   261
  size_t const alloc_time2 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   262
  size_t const alloc_amount2 = 30;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   263
  size_t const marking_time2 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   264
  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
   265
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   266
  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   267
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   268
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   269
  assert(threshold < settled_ihop1,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   270
         "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
   271
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   272
  // Third "load". Very high (impossible) allocation rate.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   273
  size_t const alloc_time3 = 1;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   274
  size_t const alloc_amount3 = 50;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   275
  size_t const marking_time3 = 2;
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   276
  size_t const settled_ihop3 = 0;
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
  test_update(&ctrl, alloc_time3, alloc_amount3, young_size, marking_time3);
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   279
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   280
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 " SIZE_FORMAT " but is " SIZE_FORMAT, settled_ihop3, threshold);
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
  // And back to some arbitrary value.
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   285
  test_update(&ctrl, alloc_time2, alloc_amount2, young_size, marking_time2);
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
  threshold = ctrl.get_conc_mark_start_threshold();
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   288
  assert(threshold > settled_ihop3,
3fdfdda0ac1f 8136678: Implement adaptive sizing algorithm for IHOP
tschatzl
parents: 34298
diff changeset
   289
         "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
   290
}
34298
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   291
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   292
void IHOP_test() {
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   293
  G1StaticIHOPControl::test();
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   294
}
f3c9dcc5af96 8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff changeset
   295
#endif