author | stuefe |
Thu, 12 Sep 2019 07:57:00 +0200 | |
branch | stuefe-new-metaspace-branch |
changeset 58099 | 5aeb07390c74 |
parent 58063 | bdf136b8ae0e |
child 58883 | 08102295011d |
permissions | -rw-r--r-- |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
1 |
/* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, SAP SE. All rights reserved. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
3 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
5 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
6 |
* This code is free software; you can redistribute it and/or modify it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
9 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
14 |
* accompanied this code). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
15 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
16 |
* You should have received a copy of the GNU General Public License version |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
19 |
* |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
21 |
* or visit www.oracle.com if you need additional information or have any |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
22 |
* questions. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
23 |
*/ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
24 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
25 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
26 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
27 |
#include "precompiled.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
28 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
29 |
#define LOG_PLEASE |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
30 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
31 |
#include "metaspace/metaspaceTestsCommon.hpp" |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
32 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
33 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
34 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
35 |
// See spaceManager.cpp : needed for predicting commit sizes. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
36 |
namespace metaspace { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
37 |
extern size_t get_raw_allocation_word_size(size_t net_word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
38 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
39 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
40 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
41 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
42 |
class SpaceManagerTest { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
43 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
44 |
// One global chunk manager, with an assiociated global virtual space list as backing, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
45 |
// and a number of space managers feeding from that manager in parallel. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
46 |
CommitLimiter _commit_limiter; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
47 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
48 |
const size_t _avg_occupancy; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
49 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
50 |
VirtualSpaceList* _vslist; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
51 |
ChunkManager* _cm; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
52 |
const ChunkAllocSequence* _alloc_sequence; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
53 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
54 |
const int _num_spaces; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
55 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
56 |
size_t _rss_at_start; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
57 |
size_t _rss_at_end; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
58 |
size_t _rss_after_cleanup; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
59 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
60 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
61 |
// A little test bed holding one SpaceManager and its lock |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
62 |
// and keeping track of its allocations. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
63 |
struct SpaceManagerTestBed : public CHeapObj<mtInternal> { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
64 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
65 |
Mutex* _lock; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
66 |
SpaceManager* _sm; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
67 |
int _index; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
68 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
69 |
// We keep track of individual allocations. Note that this adds |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
70 |
// 256K per instance of SpaceManagerTestBed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
71 |
struct allocation_t { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
72 |
MetaWord* p; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
73 |
size_t word_size; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
74 |
}; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
75 |
static const int _max_allocations = 0x4000; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
76 |
int _num_allocations; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
77 |
size_t _words_allocated; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
78 |
allocation_t _allocations[_max_allocations]; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
79 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
80 |
// Note: used counter contains "used" from the chunk perspective, which is |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
81 |
// used + freelist + alignment corrections. This does not translate 1:1 to |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
82 |
// _words_allocated, so this is difficult to test. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
83 |
SizeAtomicCounter _used_counter; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
84 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
85 |
public: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
86 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
87 |
SpaceManager* sm() { return _sm; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
88 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
89 |
SpaceManagerTestBed(int index, ChunkManager* cm, const ChunkAllocSequence* alloc_sequence) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
90 |
: _lock(NULL), _sm(NULL), _index(index), _num_allocations(0), _words_allocated(0) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
91 |
{ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
92 |
memset(_allocations, 0, sizeof(_allocations)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
93 |
_lock = new Mutex(Monitor::native, "gtest-SpaceManagerTestBed-lock", false, Monitor::_safepoint_check_never); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
94 |
{ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
95 |
// Pull lock during space creation, since this is what happens in the VM too |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
96 |
// (see ClassLoaderData::metaspace_non_null(), which we mimick here). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
97 |
MutexLocker ml(_lock, Mutex::_no_safepoint_check_flag); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
98 |
_sm = new SpaceManager(cm, alloc_sequence, _lock, &_used_counter, "gtest-SpaceManagerTestBed-sm"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
99 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
100 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
101 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
102 |
~SpaceManagerTestBed() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
103 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
104 |
// EXPECT_EQ(_used_counter.get(), _words_allocated); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
105 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
106 |
// Iterate thru all allocation records and test content first. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
107 |
for (int i = 0; i < _num_allocations; i ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
108 |
const allocation_t* al = _allocations + i; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
109 |
EXPECT_TRUE(al->p == NULL || check_marked_range(al->p, (uintx)this, al->word_size)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
110 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
111 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
112 |
// Delete SpaceManager. That should clean up all metaspace. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
113 |
delete _sm; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
114 |
delete _lock; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
115 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
116 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
117 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
118 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
119 |
size_t words_allocated() const { return _words_allocated; } |
58099 | 120 |
int num_allocations() const { return _num_allocations; } |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
121 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
122 |
int index() const { return _index; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
123 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
124 |
bool is_full() const { return _num_allocations == _max_allocations; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
125 |
bool is_empty() const { return _num_allocations == 0; } |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
126 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
127 |
// Allocate from space. Returns NULL if either the bed is full or if the allocation |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
128 |
// itself failed. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
129 |
MetaWord* allocate_and_test(size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
130 |
if (is_full()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
131 |
return NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
132 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
133 |
MetaWord* p = _sm->allocate(word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
134 |
if (p != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
135 |
EXPECT_TRUE(is_aligned(p, sizeof(void*))); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
136 |
mark_range(p, (uintx)this, word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
137 |
// Remember this allocation. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
138 |
allocation_t* al = _allocations + _num_allocations; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
139 |
al->p = p; al->word_size = word_size; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
140 |
_num_allocations ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
141 |
_words_allocated += word_size; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
142 |
// EXPECT_EQ(_used_counter.get(), _words_allocated); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
143 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
144 |
return p; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
145 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
146 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
147 |
// Deallocate the last allocation done. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
148 |
void deallocate_last() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
149 |
assert(_num_allocations > 0, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
150 |
allocation_t* al = &_allocations[_num_allocations - 1]; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
151 |
_sm->deallocate(al->p, al->word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
152 |
al->p = NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
153 |
_num_allocations --; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
154 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
155 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
156 |
// Deallocate a random single allocation. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
157 |
void deallocate_random() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
158 |
if (_num_allocations > 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
159 |
int idx = os::random() % _num_allocations; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
160 |
allocation_t* al = _allocations + idx; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
161 |
if (al->p == NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
162 |
// already deallocated? Should still have its old word size set |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
163 |
assert(al->word_size > 0, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
164 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
165 |
_sm->deallocate(al->p, al->word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
166 |
al->p = NULL; // but leave word_size, see above |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
167 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
168 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
169 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
170 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
171 |
}; // End: SpaceManagerTestBed |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
172 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
173 |
SpaceManagerTestBed** _testbeds; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
174 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
175 |
SpaceManagerTestBed* testbed_at(int index) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
176 |
assert(index < _num_spaces, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
177 |
// Create on the fly if necessary. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
178 |
if (_testbeds[index] == NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
179 |
_testbeds[index] = new SpaceManagerTestBed(index, _cm, _alloc_sequence); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
180 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
181 |
return _testbeds[index]; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
182 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
183 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
184 |
SpaceManagerTestBed* next_testbed(SpaceManagerTestBed* bed) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
185 |
int i = bed->index() + 1; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
186 |
if (i == _num_spaces) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
187 |
i = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
188 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
189 |
return testbed_at(i); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
190 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
191 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
192 |
SpaceManagerTestBed* get_random_testbed() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
193 |
const int index = os::random() % _num_spaces; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
194 |
return testbed_at(index); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
195 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
196 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
197 |
SpaceManagerTestBed* get_random_matching_testbed(bool should_be_empty) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
198 |
const int start_index = os::random() % _num_spaces; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
199 |
int i = start_index; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
200 |
do { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
201 |
SpaceManagerTestBed* bed = testbed_at(i); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
202 |
if ((should_be_empty && bed->words_allocated() == 0) || |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
203 |
(!should_be_empty && bed->words_allocated() > 0)) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
204 |
return bed; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
205 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
206 |
i ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
207 |
if (i == _num_spaces) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
208 |
i = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
209 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
210 |
} while (i != start_index); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
211 |
return NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
212 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
213 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
214 |
SpaceManagerTestBed* get_random_nonempty_testbed() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
215 |
return get_random_matching_testbed(false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
216 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
217 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
218 |
SpaceManagerTestBed* get_random_empty_testbed() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
219 |
return get_random_matching_testbed(true); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
220 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
221 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
222 |
MetaWord* alloc_from_testbed(SpaceManagerTestBed* bed, size_t word_size) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
223 |
MetaWord* p = bed->allocate_and_test(word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
224 |
if (p == NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
225 |
// Getting NULL back may mean: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
226 |
// - testbed is full. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
227 |
// - We hit the commit limit. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
228 |
if (!bed->is_full()) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
229 |
EXPECT_LT(_commit_limiter.possible_expansion_words(), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
230 |
metaspace::get_raw_allocation_word_size(word_size)); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
231 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
232 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
233 |
return p; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
234 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
235 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
236 |
void delete_testbed_at(int index) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
237 |
delete _testbeds[index]; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
238 |
_testbeds[index] = NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
239 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
240 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
241 |
void delete_testbed(SpaceManagerTestBed* bed) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
242 |
assert(_testbeds[bed->index()] == bed, "Sanity"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
243 |
_testbeds[bed->index()] = NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
244 |
delete bed; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
245 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
246 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
247 |
// Allocate multiple times random sizes from a single spacemanager. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
248 |
// Will stop allocation prematurely if per-space max is reached or if commit limit is reached. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
249 |
bool allocate_multiple_random(SpaceManagerTestBed* bed, int num_allocations, RandSizeGenerator* rgen) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
250 |
for (int n = 0; n < num_allocations; n ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
251 |
const size_t alloc_size = rgen->get(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
252 |
if (alloc_from_testbed(bed, alloc_size) == NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
253 |
return false; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
254 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
255 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
256 |
return true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
257 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
258 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
259 |
int get_total_number_of_allocations() const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
260 |
int sum = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
261 |
for (int i = 0; i < _num_spaces; i ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
262 |
if (_testbeds[i] != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
263 |
sum += _testbeds[i]->num_allocations(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
264 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
265 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
266 |
return sum; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
267 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
268 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
269 |
size_t get_total_words_allocated() const { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
270 |
size_t sum = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
271 |
for (int i = 0; i < _num_spaces; i ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
272 |
if (_testbeds[i] != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
273 |
sum += _testbeds[i]->words_allocated(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
274 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
275 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
276 |
return sum; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
277 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
278 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
279 |
// Allocate until you reach avg occupancy, hover there by allocating/freeing. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
280 |
void test_hover(int num_cycles, int avg_allocs_per_space_manager, RandSizeGenerator* rgen, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
281 |
bool exercise_reclaim, bool exercise_dealloc) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
282 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
283 |
int alloc_cycles = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
284 |
int free_cycles = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
285 |
for (int cyc = 0; cyc < num_cycles; cyc ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
286 |
if (get_total_words_allocated() < _avg_occupancy) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
287 |
SpaceManagerTestBed* bed = get_random_testbed(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
288 |
if (allocate_multiple_random(bed, avg_allocs_per_space_manager, rgen)) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
289 |
alloc_cycles ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
290 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
291 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
292 |
SpaceManagerTestBed* bed = get_random_nonempty_testbed(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
293 |
if (bed != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
294 |
free_cycles ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
295 |
delete_testbed(bed); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
296 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
297 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
298 |
if (exercise_dealloc) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
299 |
if (os::random() % 100 > 95) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
300 |
SpaceManagerTestBed* bed = get_random_nonempty_testbed(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
301 |
if (bed != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
302 |
bed->deallocate_random(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
303 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
304 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
305 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
306 |
if (cyc % 100 == 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
307 |
const size_t committed_before = _vslist->committed_words(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
308 |
if (exercise_reclaim) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
309 |
_cm->wholesale_reclaim(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
310 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
311 |
LOG("cyc: %d (a %d f %d) allocated: " SIZE_FORMAT ", committed " SIZE_FORMAT "->" SIZE_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
312 |
cyc, alloc_cycles, free_cycles, get_total_words_allocated(), committed_before, _vslist->committed_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
313 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
314 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
315 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
316 |
// _vslist->print_on(tty); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
317 |
// _cm->print_on(tty); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
318 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
319 |
} // end: test_hover |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
320 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
321 |
// Allocate until you reach avg occupancy, then drain completely. Repeat. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
322 |
void test_wave(int num_cycles, int avg_allocs_per_space_manager, RandSizeGenerator* rgen, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
323 |
bool exercise_reclaim, bool exercise_dealloc) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
324 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
325 |
bool rising = true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
326 |
int num_waves = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
327 |
for (int cyc = 0; cyc < num_cycles; cyc ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
328 |
if (rising) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
329 |
num_waves ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
330 |
if (get_total_words_allocated() >= _avg_occupancy) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
331 |
rising = false; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
332 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
333 |
SpaceManagerTestBed* bed = get_random_testbed(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
334 |
allocate_multiple_random(bed, avg_allocs_per_space_manager, rgen); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
335 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
336 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
337 |
SpaceManagerTestBed* bed = get_random_nonempty_testbed(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
338 |
if (bed == NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
339 |
EXPECT_EQ(get_total_words_allocated(), (size_t)0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
340 |
rising = true; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
341 |
} else { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
342 |
delete_testbed(bed); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
343 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
344 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
345 |
if (exercise_dealloc) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
346 |
if (os::random() % 100 > 95) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
347 |
SpaceManagerTestBed* bed = get_random_nonempty_testbed(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
348 |
if (bed != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
349 |
bed->deallocate_random(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
350 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
351 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
352 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
353 |
if (cyc % 100 == 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
354 |
LOG("cyc: %d num waves: %d num allocations: %d , words allocated: " SIZE_FORMAT ", committed " SIZE_FORMAT ".", |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
355 |
cyc, num_waves, get_total_number_of_allocations(), get_total_words_allocated(), _vslist->committed_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
356 |
const size_t committed_before = _vslist->committed_words(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
357 |
if (exercise_reclaim) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
358 |
_cm->wholesale_reclaim(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
359 |
LOG(".. reclaim: " SIZE_FORMAT "->" SIZE_FORMAT ".", committed_before, _vslist->committed_words()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
360 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
361 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
362 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
363 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
364 |
// _vslist->print_on(tty); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
365 |
// _cm->print_on(tty); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
366 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
367 |
} // end: test_wave |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
368 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
369 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
370 |
static void check_sm_stat_is_empty(sm_stats_t& stat) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
371 |
in_use_chunk_stats_t totals = stat.totals(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
372 |
EXPECT_EQ(totals.word_size, (size_t)0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
373 |
EXPECT_EQ(totals.committed_words, (size_t)0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
374 |
EXPECT_EQ(totals.used_words, (size_t)0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
375 |
EXPECT_EQ(totals.free_words, (size_t)0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
376 |
EXPECT_EQ(totals.waste_words, (size_t)0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
377 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
378 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
379 |
static void check_sm_stat_is_consistent(sm_stats_t& stat) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
380 |
in_use_chunk_stats_t totals = stat.totals(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
381 |
EXPECT_GE(totals.word_size, totals.committed_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
382 |
EXPECT_EQ(totals.committed_words, totals.used_words + totals.free_words + totals.waste_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
383 |
EXPECT_GE(totals.used_words, stat.free_blocks_word_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
384 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
385 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
386 |
void test_total_statistics() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
387 |
sm_stats_t totals1; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
388 |
check_sm_stat_is_empty(totals1); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
389 |
sm_stats_t totals2; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
390 |
check_sm_stat_is_empty(totals1); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
391 |
for (int i = 0; i < _num_spaces; i ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
392 |
if (_testbeds[i] != NULL) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
393 |
sm_stats_t stat; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
394 |
_testbeds[i]->_sm->add_to_statistics(&stat); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
395 |
check_sm_stat_is_consistent(stat); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
396 |
DEBUG_ONLY(stat.verify()); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
397 |
_testbeds[i]->_sm->add_to_statistics(&totals1); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
398 |
check_sm_stat_is_consistent(totals1); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
399 |
totals2.add(stat); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
400 |
check_sm_stat_is_consistent(totals2); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
401 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
402 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
403 |
EXPECT_EQ(totals1.totals().used_words, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
404 |
totals2.totals().used_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
405 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
406 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
407 |
public: |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
408 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
409 |
void run_test(int num_cycles, int avg_allocs_per_space_manager, RandSizeGenerator* rgen, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
410 |
bool exercise_reclaim, bool exercise_dealloc) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
411 |
LOG("hover test"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
412 |
test_hover(num_cycles, avg_allocs_per_space_manager, rgen, exercise_reclaim, exercise_dealloc); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
413 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
414 |
test_total_statistics(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
415 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
416 |
LOG("wave test"); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
417 |
test_wave(num_cycles, avg_allocs_per_space_manager, rgen, exercise_reclaim, exercise_dealloc); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
418 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
419 |
test_total_statistics(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
420 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
421 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
422 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
423 |
SpaceManagerTest(int num_spaces, size_t avg_occupancy, size_t max_commit_limit, const ChunkAllocSequence* alloc_sequence) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
424 |
: _commit_limiter(max_commit_limit), _avg_occupancy(avg_occupancy), _vslist(NULL), _cm(NULL), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
425 |
_alloc_sequence(alloc_sequence), _num_spaces(num_spaces), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
426 |
_rss_at_start(0), _rss_at_end(0), _rss_after_cleanup(0), |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
427 |
_testbeds(NULL) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
428 |
{ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
429 |
_rss_at_start = get_workingset_size(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
430 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
431 |
// Allocate test bed array |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
432 |
_testbeds = NEW_C_HEAP_ARRAY(SpaceManagerTestBed*, _num_spaces, mtInternal); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
433 |
for (int i = 0; i < _num_spaces; i ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
434 |
_testbeds[i] = NULL; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
435 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
436 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
437 |
// Create VirtualSpaceList and ChunkManager as backing memory |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
438 |
_vslist = new VirtualSpaceList("test_vs", &_commit_limiter); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
439 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
440 |
_cm = new ChunkManager("test_cm", _vslist); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
441 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
442 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
443 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
444 |
~SpaceManagerTest () { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
445 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
446 |
_rss_at_end = get_workingset_size(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
447 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
448 |
// Is the memory footprint abnormal? This is necessarily very fuzzy. The memory footprint of these tests |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
449 |
// is dominated by all metaspace allocations done and the number of spaces, since the SpaceManagerTestBed |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
450 |
// - due to the fact that we track individual allocations - is rather big. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
451 |
const size_t reasonable_expected_footprint = _avg_occupancy * BytesPerWord + |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
452 |
sizeof(SpaceManagerTestBed) * _num_spaces + |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
453 |
sizeof(SpaceManagerTestBed*) * _num_spaces + |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
454 |
sizeof(ChunkManager) + sizeof(VirtualSpaceList); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
455 |
const size_t reasonable_expected_footprint_with_margin = |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
456 |
(reasonable_expected_footprint * 2) + 1 * M; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
457 |
EXPECT_LE(_rss_at_end, _rss_at_start + reasonable_expected_footprint_with_margin); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
458 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
459 |
for (int i = 0; i < _num_spaces; i ++) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
460 |
delete _testbeds[i]; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
461 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
462 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
463 |
FREE_C_HEAP_ARRAY(SpaceManagerTestBed*, _testbeds); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
464 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
465 |
delete _cm; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
466 |
delete _vslist; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
467 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
468 |
_rss_after_cleanup = get_workingset_size(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
469 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
470 |
// Check for memory leaks. We should ideally be at the baseline of _rss_at_start. However, this depends |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
471 |
// on whether this gtest was executed as a first test in the suite, since gtest suite adds overhead of 2-4 MB. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
472 |
EXPECT_LE(_rss_after_cleanup, _rss_at_start + 4 * M); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
473 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
474 |
LOG("rss at start: " INTX_FORMAT ", at end " INTX_FORMAT " (" INTX_FORMAT "), after cleanup: " INTX_FORMAT " (" INTX_FORMAT ").", \ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
475 |
_rss_at_start, _rss_at_end, _rss_at_end - _rss_at_start, _rss_after_cleanup, _rss_after_cleanup - _rss_at_start); \ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
476 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
477 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
478 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
479 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
480 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
481 |
void test_deallocation_in_place() { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
482 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
483 |
// When deallocating, it is attempted to deallocate in place, i.e. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
484 |
// if the allocation is the most recent one, the current usage pointer |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
485 |
// in the current chunk is just reversed back to its original position |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
486 |
// before the original allocation. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
487 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
488 |
// But in-place-deallocation will not reverse allocation of the |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
489 |
// current chunk itself if its usage pointer reaches 0 due to in-place |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
490 |
// deallocation! |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
491 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
492 |
// In theory, allocating n times, then deallocation in reverse order should |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
493 |
// happin in place and at the end the usage counter of the Space Manager should |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
494 |
// be at the original place. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
495 |
// However, this is fragile, since when one of the allocations happens to |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
496 |
// cause the current chunk to be retired and a new one created, the chain |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
497 |
// breaks at that point (one cannot deallocate in-place from a non-current chunk). |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
498 |
// |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
499 |
// Therefore, to make this test reliable, we work on a new empty testbed - so |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
500 |
// we have a fresh chunk - and with miniscule allocation sizes, to not |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
501 |
// cause allocation beyond the smallest possible chunk size. That way we |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
502 |
// will never cause the initial chunk to be retired, regardless of how small it |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
503 |
// is. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
504 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
505 |
delete_testbed_at(0); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
506 |
SpaceManagerTestBed* bed = testbed_at(0); // new bed |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
507 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
508 |
const int num_loops = 5; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
509 |
const size_t max_alloc_size = metaspace::chklvl::MIN_CHUNK_WORD_SIZE / num_loops * 2; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
510 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
511 |
// Doing this multiple times should work too as long as we keep the |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
512 |
// reverse allocation order. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
513 |
sm_stats_t stat[10]; // taken before each allocation |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
514 |
size_t alloc_sizes[10] = { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
515 |
max_alloc_size, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
516 |
1, 2, 3, // <- small sizes to have difference between raw size and net size |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
517 |
0, 0, 0, 0, 0, 0 // <- use random values; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
518 |
}; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
519 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
520 |
RandSizeGenerator rgen(1, max_alloc_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
521 |
int i = 0; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
522 |
while (i < 10) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
523 |
// take stats before allocating... |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
524 |
bed->sm()->add_to_statistics(stat + i); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
525 |
check_sm_stat_is_consistent(stat[i]); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
526 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
527 |
// and allocate. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
528 |
LOG("alloc round #%d (used: " SIZE_FORMAT ").", i, stat[i].totals().used_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
529 |
const size_t alloc_size = alloc_sizes[i] > 0 ? alloc_sizes[i] : rgen.get(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
530 |
MetaWord* p = bed->allocate_and_test(alloc_size); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
531 |
ASSERT_NOT_NULL(p); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
532 |
i ++; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
533 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
534 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
535 |
// Now reverse-deallocate and compare used_words while doing so. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
536 |
// (Note: used_words should be the same after deallocating as before the |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
537 |
// original allocation. All other stats cannot be relied on being the same.) |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
538 |
i --; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
539 |
while (i >= 0) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
540 |
// dealloc, measure statistics after each deallocation and compare with |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
541 |
// the statistics taken at allocation time. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
542 |
LOG("dealloc round #%d", i); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
543 |
bed->deallocate_last(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
544 |
sm_stats_t stat_now; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
545 |
bed->sm()->add_to_statistics(&stat_now); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
546 |
check_sm_stat_is_consistent(stat_now); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
547 |
ASSERT_EQ(stat_now.totals().used_words, |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
548 |
stat[i].totals().used_words); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
549 |
i --; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
550 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
551 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
552 |
} // end: test_deallocation_in_place |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
553 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
554 |
}; |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
555 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
556 |
// for convenience, here some shorthands for standard alloc sequences. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
557 |
static const ChunkAllocSequence* const g_standard_allocseq_class = |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
558 |
ChunkAllocSequence::alloc_sequence_by_space_type(metaspace::StandardMetaspaceType, true); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
559 |
static const ChunkAllocSequence* const g_standard_allocseq_nonclass = |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
560 |
ChunkAllocSequence::alloc_sequence_by_space_type(metaspace::StandardMetaspaceType, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
561 |
static const ChunkAllocSequence* const g_boot_allocseq_class = |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
562 |
ChunkAllocSequence::alloc_sequence_by_space_type(metaspace::BootMetaspaceType, true); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
563 |
static const ChunkAllocSequence* const g_boot_allocseq_nonclass = |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
564 |
ChunkAllocSequence::alloc_sequence_by_space_type(metaspace::BootMetaspaceType, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
565 |
static const ChunkAllocSequence* const g_refl_allocseq_class = |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
566 |
ChunkAllocSequence::alloc_sequence_by_space_type(metaspace::ReflectionMetaspaceType, true); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
567 |
static const ChunkAllocSequence* const g_refl_allocseq_nonclass = |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
568 |
ChunkAllocSequence::alloc_sequence_by_space_type(metaspace::ReflectionMetaspaceType, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
569 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
570 |
// Some standard random size gens. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
571 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
572 |
// generates sizes between 1 and 128 words. |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
573 |
static RandSizeGenerator rgen_1K_no_outliers(1, 128); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
574 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
575 |
// generates sizes between 1 and 256 words, small chance of large outliers |
58099 | 576 |
static RandSizeGenerator rgen_1K_some_huge_outliers(1, 256, 0.05f, MAX_CHUNK_WORD_SIZE / 64, MAX_CHUNK_WORD_SIZE / 2); |
58063
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
577 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
578 |
// generates medium sized sizes |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
579 |
static RandSizeGenerator rgen_32K_no_outliers(128, 0x4000); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
580 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
581 |
// large (and pretty unrealistic) spread |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
582 |
static RandSizeGenerator rgen_large_spread(1, MAX_CHUNK_WORD_SIZE); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
583 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
584 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
585 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
586 |
#define TEST_WITH_PARAMS(name, num_spaces, avg_occ, commit_limit, alloc_seq, rgen, exercise_reclaim, exercise_dealloc) \ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
587 |
TEST_VM(metaspace, space_manager_test_##name) { \ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
588 |
SpaceManagerTest stest(num_spaces, avg_occ, commit_limit, alloc_seq); \ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
589 |
stest.run_test(1000, 50, &rgen, exercise_reclaim, exercise_dealloc); \ |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
590 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
591 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
592 |
TEST_WITH_PARAMS(test0, 1, 64 * K, SIZE_MAX, g_standard_allocseq_nonclass, rgen_1K_no_outliers, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
593 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
594 |
TEST_WITH_PARAMS(test1, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_1K_no_outliers, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
595 |
TEST_WITH_PARAMS(test2, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_1K_no_outliers, false, true); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
596 |
TEST_WITH_PARAMS(test3, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_1K_no_outliers, false, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
597 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
598 |
TEST_WITH_PARAMS(test4, 10, 1 * M, SIZE_MAX, g_boot_allocseq_nonclass, rgen_1K_no_outliers, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
599 |
TEST_WITH_PARAMS(test5, 10, 1 * M, SIZE_MAX, g_boot_allocseq_nonclass, rgen_1K_no_outliers, false, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
600 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
601 |
TEST_WITH_PARAMS(test6, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_1K_some_huge_outliers, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
602 |
TEST_WITH_PARAMS(test7, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_1K_some_huge_outliers, false, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
603 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
604 |
TEST_WITH_PARAMS(test8, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_32K_no_outliers, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
605 |
TEST_WITH_PARAMS(test9, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_32K_no_outliers, false, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
606 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
607 |
TEST_WITH_PARAMS(test10, 10, 10 * M, 2 * M, g_standard_allocseq_nonclass, rgen_1K_some_huge_outliers, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
608 |
TEST_WITH_PARAMS(test11, 10, 10 * M, 2 * M, g_standard_allocseq_nonclass, rgen_1K_some_huge_outliers, false, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
609 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
610 |
TEST_WITH_PARAMS(test12, 10, 10 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_large_spread, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
611 |
TEST_WITH_PARAMS(test13, 10, 10 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_large_spread, false, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
612 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
613 |
TEST_WITH_PARAMS(test_14, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_32K_no_outliers, true, true); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
614 |
TEST_WITH_PARAMS(test_15, 10, 1 * M, SIZE_MAX, g_standard_allocseq_nonclass, rgen_large_spread, true, false); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
615 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
616 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
617 |
TEST_VM(metaspace, space_manager_test_deallocation_in_place) { |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
618 |
// Test deallocation with no commit limit |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
619 |
SpaceManagerTest stest(1, 1 * M, 2 * M, g_boot_allocseq_class); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
620 |
stest.test_deallocation_in_place(); |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
621 |
} |
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
622 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
623 |
|
bdf136b8ae0e
Initial changes for new metaspace. Only tested for Linux x64.
stuefe
parents:
diff
changeset
|
624 |