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 |
#ifndef SHARE_VM_GC_G1_G1IHOPCONTROL_HPP |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
26 |
#define SHARE_VM_GC_G1_G1IHOPCONTROL_HPP |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
27 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
28 |
#include "memory/allocation.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 |
// Base class for algorithms that calculate the heap occupancy at which |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
31 |
// concurrent marking should start. This heap usage threshold should be relative |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
32 |
// to old gen size. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
33 |
class G1IHOPControl : public CHeapObj<mtGC> { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
34 |
protected: |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
35 |
// The initial IHOP value relative to the target occupancy. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
36 |
double _initial_ihop_percent; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
37 |
// The target maximum occupancy of the heap. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
38 |
size_t _target_occupancy; |
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 |
// Most recent complete mutator allocation period in seconds. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
41 |
double _last_allocation_time_s; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
42 |
// Amount of bytes allocated during _last_allocation_time_s. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
43 |
size_t _last_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 |
// Initialize an instance with the initial IHOP value in percent and the target |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
46 |
// occupancy. The target occupancy is the number of bytes when marking should |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
47 |
// be finished and reclaim started. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
48 |
G1IHOPControl(double initial_ihop_percent, size_t target_occupancy); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
49 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
50 |
// Most recent time from the end of the initial mark to the start of the first |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
51 |
// mixed gc. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
52 |
virtual double last_marking_length_s() const = 0; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
53 |
public: |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
54 |
virtual ~G1IHOPControl() { } |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
55 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
56 |
// Get the current non-young occupancy at which concurrent marking should start. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
57 |
virtual size_t get_conc_mark_start_threshold() = 0; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
58 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
59 |
// Update information about time during which allocations in the Java heap occurred, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
60 |
// how large these allocations were in bytes, and an additional buffer. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
61 |
// The allocations should contain any amount of space made unusable for further |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
62 |
// allocation, e.g. any waste caused by TLAB allocation, space at the end of |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
63 |
// humongous objects that can not be used for allocation, etc. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
64 |
// Together with the target occupancy, this additional buffer should contain the |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
65 |
// difference between old gen size and total heap size at the start of reclamation, |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
66 |
// and space required for that reclamation. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
67 |
virtual void 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
|
68 |
// Update the time spent in the mutator beginning from the end of initial mark to |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
69 |
// the first mixed gc. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
70 |
virtual void update_marking_length(double marking_length_s) = 0; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
71 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
72 |
virtual void print(); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
73 |
}; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
74 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
75 |
// The returned concurrent mark starting occupancy threshold is a fixed value |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
76 |
// relative to the maximum heap size. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
77 |
class G1StaticIHOPControl : public G1IHOPControl { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
78 |
// Most recent mutator time between the end of initial mark to the start of the |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
79 |
// first mixed gc. |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
80 |
double _last_marking_length_s; |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
81 |
protected: |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
82 |
double last_marking_length_s() const { return _last_marking_length_s; } |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
83 |
public: |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
84 |
G1StaticIHOPControl(double ihop_percent, size_t target_occupancy); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
85 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
86 |
size_t get_conc_mark_start_threshold() { return (size_t) (_initial_ihop_percent * _target_occupancy / 100.0); } |
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 |
virtual void update_marking_length(double marking_length_s) { |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
89 |
assert(marking_length_s > 0.0, "Marking length must be larger than zero but is %.3f", marking_length_s); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
90 |
_last_marking_length_s = marking_length_s; |
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 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
93 |
#ifndef PRODUCT |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
94 |
static void test(); |
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
95 |
#endif |
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 |
|
f3c9dcc5af96
8136681: Factor out IHOP calculation from G1CollectorPolicy
tschatzl
parents:
diff
changeset
|
98 |
#endif // SHARE_VM_GC_G1_G1IHOPCONTROL_HPP |