author | david |
Tue, 29 Sep 2015 11:02:08 +0200 | |
changeset 33105 | 294e48b4f704 |
parent 32378 | 8dd0e7359751 |
child 35061 | be6025ebffea |
permissions | -rw-r--r-- |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
1 |
/* |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
2 |
* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
4 |
* |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
8 |
* |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
13 |
* accompanied this code). |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
14 |
* |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
18 |
* |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
21 |
* questions. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
22 |
* |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
23 |
*/ |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
24 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/shared/collectedHeap.hpp" |
32378
8dd0e7359751
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents:
31632
diff
changeset
|
27 |
#include "gc/shared/plab.inline.hpp" |
30764 | 28 |
#include "gc/shared/threadLocalAllocBuffer.hpp" |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
29 |
#include "oops/arrayOop.hpp" |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
30 |
#include "oops/oop.inline.hpp" |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
31 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
32 |
size_t PLAB::min_size() { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
33 |
// Make sure that we return something that is larger than AlignmentReserve |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
34 |
return align_object_size(MAX2(MinTLABSize / HeapWordSize, (uintx)oopDesc::header_size())) + AlignmentReserve; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
35 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
36 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
37 |
size_t PLAB::max_size() { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
38 |
return ThreadLocalAllocBuffer::max_size(); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
39 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
40 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
41 |
PLAB::PLAB(size_t desired_plab_sz_) : |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
42 |
_word_sz(desired_plab_sz_), _bottom(NULL), _top(NULL), |
30564
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
43 |
_end(NULL), _hard_end(NULL), _allocated(0), _wasted(0), _undo_wasted(0) |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
44 |
{ |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
45 |
// ArrayOopDesc::header_size depends on command line initialization. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
46 |
AlignmentReserve = oopDesc::header_size() > MinObjAlignment ? align_object_size(arrayOopDesc::header_size(T_INT)) : 0; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
47 |
assert(min_size() > AlignmentReserve, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
48 |
"Minimum PLAB size " SIZE_FORMAT " must be larger than alignment reserve " SIZE_FORMAT " " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
49 |
"to be able to contain objects", min_size(), AlignmentReserve); |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
50 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
51 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
52 |
// If the minimum object size is greater than MinObjAlignment, we can |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
53 |
// end up with a shard at the end of the buffer that's smaller than |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
54 |
// the smallest object. We can't allow that because the buffer must |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
55 |
// look like it's full of objects when we retire it, so we make |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
56 |
// sure we have enough space for a filler int array object. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
57 |
size_t PLAB::AlignmentReserve; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
58 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
59 |
void PLAB::flush_and_retire_stats(PLABStats* stats) { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
60 |
// Retire the last allocation buffer. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
61 |
size_t unused = retire_internal(); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
62 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
63 |
// Now flush the statistics. |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
64 |
stats->add_allocated(_allocated); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
65 |
stats->add_wasted(_wasted); |
30564
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
66 |
stats->add_undo_wasted(_undo_wasted); |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
67 |
stats->add_unused(unused); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
68 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
69 |
// Since we have flushed the stats we need to clear the _allocated and _wasted |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
70 |
// fields in case somebody retains an instance of this over GCs. Not doing so |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
71 |
// will artifically inflate the values in the statistics. |
30564
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
72 |
_allocated = 0; |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
73 |
_wasted = 0; |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
74 |
_undo_wasted = 0; |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
75 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
76 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
77 |
void PLAB::retire() { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
78 |
_wasted += retire_internal(); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
79 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
80 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
81 |
size_t PLAB::retire_internal() { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
82 |
size_t result = 0; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
83 |
if (_top < _hard_end) { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
84 |
CollectedHeap::fill_with_object(_top, _hard_end); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
85 |
result += invalidate(); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
86 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
87 |
return result; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
88 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
89 |
|
30564
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
90 |
void PLAB::add_undo_waste(HeapWord* obj, size_t word_sz) { |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
91 |
CollectedHeap::fill_with_object(obj, word_sz); |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
92 |
_undo_wasted += word_sz; |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
93 |
} |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
94 |
|
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
95 |
void PLAB::undo_last_allocation(HeapWord* obj, size_t word_sz) { |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
96 |
assert(pointer_delta(_top, _bottom) >= word_sz, "Bad undo"); |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
97 |
assert(pointer_delta(_top, obj) == word_sz, "Bad undo"); |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
98 |
_top = obj; |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
99 |
} |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
100 |
|
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
101 |
void PLAB::undo_allocation(HeapWord* obj, size_t word_sz) { |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
102 |
// Is the alloc in the current alloc buffer? |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
103 |
if (contains(obj)) { |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
104 |
assert(contains(obj + word_sz - 1), |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
105 |
"should contain whole object"); |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
106 |
undo_last_allocation(obj, word_sz); |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
107 |
} else { |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
108 |
add_undo_waste(obj, word_sz); |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
109 |
} |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
110 |
} |
a37d98a1eb54
8071462: Remove G1ParGCAllocator::alloc_buffer_waste
tschatzl
parents:
30276
diff
changeset
|
111 |
|
31632
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
112 |
// Calculates plab size for current number of gc worker threads. |
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
113 |
size_t PLABStats::desired_plab_sz(uint no_of_gc_workers) { |
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
114 |
return MAX2(min_size(), (size_t)align_object_size(_desired_net_plab_sz / no_of_gc_workers)); |
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
115 |
} |
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
116 |
|
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
117 |
// Compute desired plab size for one gc worker thread and latch result for later |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
118 |
// use. This should be called once at the end of parallel |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
119 |
// scavenge; it clears the sensor accumulators. |
31632
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
120 |
void PLABStats::adjust_desired_plab_sz() { |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
121 |
assert(ResizePLAB, "Not set"); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
122 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
123 |
assert(is_object_aligned(max_size()) && min_size() <= max_size(), |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
124 |
"PLAB clipping computation may be incorrect"); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
125 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
126 |
if (_allocated == 0) { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
127 |
assert(_unused == 0, |
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
128 |
"Inconsistency in PLAB stats: " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
129 |
"_allocated: " SIZE_FORMAT ", " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
130 |
"_wasted: " SIZE_FORMAT ", " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
131 |
"_unused: " SIZE_FORMAT ", " |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
132 |
"_undo_wasted: " SIZE_FORMAT, |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32378
diff
changeset
|
133 |
_allocated, _wasted, _unused, _undo_wasted); |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
134 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
135 |
_allocated = 1; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
136 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
137 |
double wasted_frac = (double)_unused / (double)_allocated; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
138 |
size_t target_refills = (size_t)((wasted_frac * TargetSurvivorRatio) / TargetPLABWastePct); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
139 |
if (target_refills == 0) { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
140 |
target_refills = 1; |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
141 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
142 |
size_t used = _allocated - _wasted - _unused; |
31632
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
143 |
// Assumed to have 1 gc worker thread |
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
144 |
size_t recent_plab_sz = used / target_refills; |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
145 |
// Take historical weighted average |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
146 |
_filter.sample(recent_plab_sz); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
147 |
// Clip from above and below, and align to object boundary |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
148 |
size_t new_plab_sz = MAX2(min_size(), (size_t)_filter.average()); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
149 |
new_plab_sz = MIN2(max_size(), new_plab_sz); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
150 |
new_plab_sz = align_object_size(new_plab_sz); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
151 |
// Latch the result |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
152 |
if (PrintPLAB) { |
31632
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
153 |
gclog_or_tty->print(" (plab_sz = " SIZE_FORMAT " desired_net_plab_sz = " SIZE_FORMAT ") ", recent_plab_sz, new_plab_sz); |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
154 |
} |
31632
d041b34dd3e7
8079555: REDO - Determining the desired PLAB size adjusts to the the number of threads at the wrong place
sangheki
parents:
31592
diff
changeset
|
155 |
_desired_net_plab_sz = new_plab_sz; |
30275
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
156 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
157 |
reset(); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
158 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
159 |
|
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
160 |
#ifndef PRODUCT |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
161 |
void PLAB::print() { |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
162 |
gclog_or_tty->print_cr("PLAB: _bottom: " PTR_FORMAT " _top: " PTR_FORMAT |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
163 |
" _end: " PTR_FORMAT " _hard_end: " PTR_FORMAT ")", |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
164 |
p2i(_bottom), p2i(_top), p2i(_end), p2i(_hard_end)); |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
165 |
} |
41fef3a62cc8
8074546: Rename and clean up the ParGCAllocBuffer class
jprovino
parents:
diff
changeset
|
166 |
#endif // !PRODUCT |