14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/g1NUMAStats.hpp"
27 #include "logging/logStream.hpp"
28
29 double G1NUMAStats::Stat::rate() const {
30 return _requested == 0 ? 0 : (double)_hit / _requested * 100;
31 }
32
33 G1NUMAStats::NodeDataArray::NodeDataArray(uint num_nodes) {
34 // Not using > 1, for -XX:+ForceNUMA support.
35 guarantee(num_nodes > 0, "Number of nodes (%u) should be set", num_nodes);
36
37 // The row represents the number of nodes.
38 _num_column = num_nodes;
39 // +1 for G1MemoryNodeManager::AnyNodeIndex.
40 _num_row = num_nodes + 1;
41
42 _data = NEW_C_HEAP_ARRAY(size_t*, _num_row, mtGC);
43 for (uint row = 0; row < _num_row; row++) {
44 _data[row] = NEW_C_HEAP_ARRAY(size_t, _num_column, mtGC);
45 }
46
47 clear();
48 }
49
50 G1NUMAStats::NodeDataArray::~NodeDataArray() {
51 for (uint row = 0; row < _num_row; row++) {
52 FREE_C_HEAP_ARRAY(size_t, _data[row]);
53 }
54 FREE_C_HEAP_ARRAY(size_t*, _data);
55 }
56
108 for (uint row = 0; row < _num_row; row++) {
109 memset((void*)_data[row], 0, sizeof(size_t) * _num_column);
110 }
111 }
112
113 size_t G1NUMAStats::NodeDataArray::get(uint req_index, uint alloc_index) {
114 return _data[req_index][alloc_index];
115 }
116
117 void G1NUMAStats::NodeDataArray::copy(uint req_index, size_t* stat) {
118 assert(stat != NULL, "Invariant");
119
120 for (uint column = 0; column < _num_column; column++) {
121 _data[req_index][column] += stat[column];
122 }
123 }
124
125 G1NUMAStats::G1NUMAStats(const int* node_ids, uint num_node_ids) :
126 _node_ids(node_ids), _num_node_ids(num_node_ids), _node_data() {
127
128 // Not using > 1, for -XX:+ForceNUMA support.
129 assert(_num_node_ids > 0, "Should have at least one node id: %u", _num_node_ids);
130
131 for (int i = 0; i < NodeDataItemsSentinel; i++) {
132 _node_data[i] = new NodeDataArray(_num_node_ids);
133 }
134 }
135
136 G1NUMAStats::~G1NUMAStats() {
137 for (int i = 0; i < NodeDataItemsSentinel; i++) {
138 delete _node_data[i];
139 }
140 }
141
142 void G1NUMAStats::clear(G1NUMAStats::NodeDataItems phase) {
143 _node_data[phase]->clear();
144 }
145
146 void G1NUMAStats::update(G1NUMAStats::NodeDataItems phase,
147 uint requested_node_index,
148 uint allocated_node_index) {
149 _node_data[phase]->increase(requested_node_index, allocated_node_index);
|
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "gc/g1/g1NUMAStats.hpp"
27 #include "logging/logStream.hpp"
28
29 double G1NUMAStats::Stat::rate() const {
30 return _requested == 0 ? 0 : (double)_hit / _requested * 100;
31 }
32
33 G1NUMAStats::NodeDataArray::NodeDataArray(uint num_nodes) {
34 // The row represents the number of nodes.
35 _num_column = num_nodes;
36 // +1 for G1MemoryNodeManager::AnyNodeIndex.
37 _num_row = num_nodes + 1;
38
39 _data = NEW_C_HEAP_ARRAY(size_t*, _num_row, mtGC);
40 for (uint row = 0; row < _num_row; row++) {
41 _data[row] = NEW_C_HEAP_ARRAY(size_t, _num_column, mtGC);
42 }
43
44 clear();
45 }
46
47 G1NUMAStats::NodeDataArray::~NodeDataArray() {
48 for (uint row = 0; row < _num_row; row++) {
49 FREE_C_HEAP_ARRAY(size_t, _data[row]);
50 }
51 FREE_C_HEAP_ARRAY(size_t*, _data);
52 }
53
105 for (uint row = 0; row < _num_row; row++) {
106 memset((void*)_data[row], 0, sizeof(size_t) * _num_column);
107 }
108 }
109
110 size_t G1NUMAStats::NodeDataArray::get(uint req_index, uint alloc_index) {
111 return _data[req_index][alloc_index];
112 }
113
114 void G1NUMAStats::NodeDataArray::copy(uint req_index, size_t* stat) {
115 assert(stat != NULL, "Invariant");
116
117 for (uint column = 0; column < _num_column; column++) {
118 _data[req_index][column] += stat[column];
119 }
120 }
121
122 G1NUMAStats::G1NUMAStats(const int* node_ids, uint num_node_ids) :
123 _node_ids(node_ids), _num_node_ids(num_node_ids), _node_data() {
124
125 assert(_num_node_ids > 1, "Should have at least one node id: %u", _num_node_ids);
126
127 for (int i = 0; i < NodeDataItemsSentinel; i++) {
128 _node_data[i] = new NodeDataArray(_num_node_ids);
129 }
130 }
131
132 G1NUMAStats::~G1NUMAStats() {
133 for (int i = 0; i < NodeDataItemsSentinel; i++) {
134 delete _node_data[i];
135 }
136 }
137
138 void G1NUMAStats::clear(G1NUMAStats::NodeDataItems phase) {
139 _node_data[phase]->clear();
140 }
141
142 void G1NUMAStats::update(G1NUMAStats::NodeDataItems phase,
143 uint requested_node_index,
144 uint allocated_node_index) {
145 _node_data[phase]->increase(requested_node_index, allocated_node_index);
|