1 /* |
1 /* |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
44 _direct_allocated * HeapWordSize, |
44 _direct_allocated * HeapWordSize, |
45 _failure_used * HeapWordSize, |
45 _failure_used * HeapWordSize, |
46 _failure_waste * HeapWordSize); |
46 _failure_waste * HeapWordSize); |
47 } |
47 } |
48 |
48 |
49 void G1EvacStats::adjust_desired_plab_sz() { |
49 size_t G1EvacStats::compute_desired_plab_sz() { |
50 log_plab_allocation(); |
|
51 |
|
52 if (!ResizePLAB) { |
|
53 // Clear accumulators for next round. |
|
54 reset(); |
|
55 return; |
|
56 } |
|
57 |
|
58 assert(is_object_aligned(max_size()) && min_size() <= max_size(), |
|
59 "PLAB clipping computation may be incorrect"); |
|
60 |
|
61 if (_allocated == 0) { |
|
62 assert((_unused == 0), |
|
63 "Inconsistency in PLAB stats: " |
|
64 "_allocated: " SIZE_FORMAT ", " |
|
65 "_wasted: " SIZE_FORMAT ", " |
|
66 "_region_end_waste: " SIZE_FORMAT ", " |
|
67 "_unused: " SIZE_FORMAT ", " |
|
68 "_used : " SIZE_FORMAT, |
|
69 _allocated, _wasted, _region_end_waste, _unused, used()); |
|
70 _allocated = 1; |
|
71 } |
|
72 // The size of the PLAB caps the amount of space that can be wasted at the |
50 // The size of the PLAB caps the amount of space that can be wasted at the |
73 // end of the collection. In the worst case the last PLAB could be completely |
51 // end of the collection. In the worst case the last PLAB could be completely |
74 // empty. |
52 // empty. |
75 // This allows us to calculate the new PLAB size to achieve the |
53 // This allows us to calculate the new PLAB size to achieve the |
76 // TargetPLABWastePct given the latest memory usage and that the last buffer |
54 // TargetPLABWastePct given the latest memory usage and that the last buffer |
107 // which is an okay reaction. |
85 // which is an okay reaction. |
108 size_t const used_for_waste_calculation = used() > _region_end_waste ? used() - _region_end_waste : 0; |
86 size_t const used_for_waste_calculation = used() > _region_end_waste ? used() - _region_end_waste : 0; |
109 |
87 |
110 size_t const total_waste_allowed = used_for_waste_calculation * TargetPLABWastePct; |
88 size_t const total_waste_allowed = used_for_waste_calculation * TargetPLABWastePct; |
111 size_t const cur_plab_sz = (size_t)((double)total_waste_allowed / G1LastPLABAverageOccupancy); |
89 size_t const cur_plab_sz = (size_t)((double)total_waste_allowed / G1LastPLABAverageOccupancy); |
112 // Take historical weighted average |
90 return cur_plab_sz; |
113 _filter.sample(cur_plab_sz); |
|
114 _desired_net_plab_sz = MAX2(min_size(), (size_t)_filter.average()); |
|
115 |
|
116 log_sizing(cur_plab_sz, _desired_net_plab_sz); |
|
117 // Clear accumulators for next round. |
|
118 reset(); |
|
119 } |
91 } |
120 |
92 |
121 G1EvacStats::G1EvacStats(const char* description, size_t desired_plab_sz_, unsigned wt) : |
93 G1EvacStats::G1EvacStats(const char* description, size_t desired_plab_sz_, unsigned wt) : |
122 PLABStats(description, desired_plab_sz_, wt), |
94 PLABStats(description, desired_plab_sz_, wt), |
123 _region_end_waste(0), |
95 _region_end_waste(0), |