author | tschatzl |
Tue, 24 Nov 2015 10:22:36 +0100 | |
changeset 34298 | f3c9dcc5af96 |
child 34299 | 3fdfdda0ac1f |
permissions | -rw-r--r-- |
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" |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
29 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
30 |
G1IHOPControl::G1IHOPControl(double initial_ihop_percent, size_t target_occupancy) : |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
31 |
_initial_ihop_percent(initial_ihop_percent), |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
32 |
_target_occupancy(target_occupancy), |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
33 |
_last_allocated_bytes(0), |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
34 |
_last_allocation_time_s(0.0) |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
35 |
{ |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
36 |
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
|
37 |
} |
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 |
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
|
40 |
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
|
41 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
42 |
_last_allocation_time_s = allocation_time_s; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
43 |
_last_allocated_bytes = allocated_bytes; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
44 |
} |
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 |
void G1IHOPControl::print() { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
47 |
size_t cur_conc_mark_start_threshold = get_conc_mark_start_threshold(); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
48 |
ergo_verbose6(ErgoIHOP, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
49 |
"basic information", |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
50 |
ergo_format_reason("value update") |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
51 |
ergo_format_byte_perc("threshold") |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
52 |
ergo_format_byte("target occupancy") |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
53 |
ergo_format_byte("current occupancy") |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
54 |
ergo_format_double("recent old gen allocation rate") |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
55 |
ergo_format_double("recent marking phase length"), |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
56 |
cur_conc_mark_start_threshold, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
57 |
cur_conc_mark_start_threshold * 100.0 / _target_occupancy, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
58 |
_target_occupancy, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
59 |
G1CollectedHeap::heap()->used(), |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
60 |
_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
|
61 |
last_marking_length_s()); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
62 |
} |
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 |
G1StaticIHOPControl::G1StaticIHOPControl(double ihop_percent, size_t target_occupancy) : |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
65 |
G1IHOPControl(ihop_percent, target_occupancy), |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
66 |
_last_marking_length_s(0.0) { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
67 |
assert(_target_occupancy > 0, "Target occupancy must be larger than zero."); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
68 |
} |
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 |
#ifndef PRODUCT |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
71 |
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
|
72 |
for (int i = 0; i < 100; i++) { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
73 |
ctrl->update_allocation_info(alloc_time, alloc_amount, young_size); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
74 |
ctrl->update_marking_length(mark_time); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
75 |
} |
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 |
void G1StaticIHOPControl::test() { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
79 |
size_t const initial_ihop = 45; |
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 |
G1StaticIHOPControl ctrl(initial_ihop, 100); |
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 |
size_t threshold = ctrl.get_conc_mark_start_threshold(); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
84 |
assert(threshold == initial_ihop, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
85 |
"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
|
86 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
87 |
ctrl.update_allocation_info(100.0, 100, 100); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
88 |
threshold = ctrl.get_conc_mark_start_threshold(); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
89 |
assert(threshold == initial_ihop, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
90 |
"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
|
91 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
92 |
ctrl.update_marking_length(1000.0); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
93 |
threshold = ctrl.get_conc_mark_start_threshold(); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
94 |
assert(threshold == initial_ihop, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
95 |
"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
|
96 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
97 |
// Whatever we pass, the IHOP value must stay the same. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
98 |
test_update(&ctrl, 2, 10, 10, 3); |
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 |
test_update(&ctrl, 12, 10, 10, 3); |
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 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
109 |
void IHOP_test() { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
110 |
G1StaticIHOPControl::test(); |
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 |
#endif |