author | stuefe |
Sat, 23 Nov 2019 11:05:16 +0100 | |
branch | stuefe-new-metaspace-branch |
changeset 59238 | 6ce12ce00d3e |
parent 59155 | b537e6386306 |
permissions | -rw-r--r-- |
59155
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
1 |
/* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, SAP SE. All rights reserved. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
3 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
5 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
9 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
14 |
* accompanied this code). |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
15 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
19 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
22 |
* questions. |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
23 |
* |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
24 |
*/ |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
25 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
26 |
#include "precompiled.hpp" |
59238
6ce12ce00d3e
Factor out block list array from LOM since we may use it elsewhere
stuefe
parents:
59155
diff
changeset
|
27 |
#include "memory/metaspace/blockListArray.inline.hpp" |
59155
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
28 |
#include "memory/metaspace/leftOverBins.inline.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
29 |
#include "utilities/globalDefinitions.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
30 |
#include "utilities/ostream.hpp" |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
31 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
32 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
33 |
namespace metaspace { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
34 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
35 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
36 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
37 |
#ifdef ASSERT |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
38 |
void LeftOverManager::verify() const { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
39 |
_very_small_bins.verify(); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
40 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
41 |
if (_large_block_reserve != NULL) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
42 |
assert(_current != NULL, "Sanity"); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
43 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
44 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
45 |
assert( (_current == NULL && _current_size == 0) || |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
46 |
(_current != NULL && _current_size > 0), "Sanity"); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
47 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
48 |
for (block_t* b = _large_block_reserve; b != NULL; b = b->next) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
49 |
assert(b->size > 0 && b->size <= 4 * M, "Weird block size"); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
50 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
51 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
52 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
53 |
#endif |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
54 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
55 |
void LeftOverManager::large_block_statistics(block_stats_t* stats) const { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
56 |
for (block_t* b = _large_block_reserve; b != NULL; b = b->next) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
57 |
stats->num_blocks ++; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
58 |
stats->word_size += b->size; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
59 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
60 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
61 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
62 |
void LeftOverManager::statistics(block_stats_t* stats) const { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
63 |
stats->num_blocks = 0; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
64 |
stats->word_size = 0; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
65 |
_very_small_bins.statistics(stats); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
66 |
if (_current != NULL) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
67 |
stats->num_blocks ++; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
68 |
stats->word_size += _current_size; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
69 |
large_block_statistics(stats); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
70 |
} else { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
71 |
assert(_large_block_reserve == NULL, "Sanity"); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
72 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
73 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
74 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
75 |
void LeftOverManager::print(outputStream* st, bool detailed) const { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
76 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
77 |
block_stats_t s; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
78 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
79 |
if (_current != NULL) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
80 |
st->print("current: " SIZE_FORMAT " words; ", _current_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
81 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
82 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
83 |
s.num_blocks = 0; s.word_size = 0; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
84 |
large_block_statistics(&s); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
85 |
st->print("large blocks: %d blocks, " SIZE_FORMAT " words", s.num_blocks, s.word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
86 |
if (detailed) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
87 |
st->print(" ("); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
88 |
for (block_t* b = _large_block_reserve; b != NULL; b = b->next) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
89 |
st->print(SIZE_FORMAT "%s", b->size, b->next != NULL ? ", " : ""); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
90 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
91 |
st->print(")"); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
92 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
93 |
st->print("; "); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
94 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
95 |
s.num_blocks = 0; s.word_size = 0; |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
96 |
_very_small_bins.statistics(&s); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
97 |
st->print("small blocks: %d blocks, " SIZE_FORMAT " words", s.num_blocks, s.word_size); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
98 |
if (detailed) { |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
99 |
st->print(" ("); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
100 |
_very_small_bins.print(st); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
101 |
st->print(")"); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
102 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
103 |
st->print("; "); |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
104 |
} |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
105 |
|
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
106 |
} // namespace metaspace |
b537e6386306
LeftOverBins as an optional replacement of free block dictionary which is rather ineffective
stuefe
parents:
diff
changeset
|
107 |