|
1 /* |
|
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
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 #ifndef SHARE_VM_GC_G1_NODE_TIMES_HPP |
|
26 #define SHARE_VM_GC_G1_NODE_TIMES_HPP |
|
27 |
|
28 #include "memory/allocation.hpp" |
|
29 |
|
30 // Manages statistics of multi nodes. |
|
31 class G1NUMAStats : public CHeapObj<mtGC> { |
|
32 struct Stat { |
|
33 // Hit count: if requested id equals to returned id. |
|
34 size_t _hit; |
|
35 // Total request count |
|
36 size_t _requested; |
|
37 |
|
38 // Hit count / total request count |
|
39 double rate() const; |
|
40 }; |
|
41 |
|
42 // Holds data array which has a size of (node count) * (node count + 1) to |
|
43 // represent request node * allocated node. The request node includes any node case. |
|
44 // All operations are NOT thread-safe. |
|
45 // The row index indicates a requested node index while the column node index |
|
46 // indicates an allocated node index. The last row is for any node index request. |
|
47 // E.g. (req, alloc) = (0,0) (1,0) (2,0) (0,1) (Any, 3) (0,2) (0,3) (0,3) (3,3) |
|
48 // Allocated node index 0 1 2 3 Total |
|
49 // Requested node index 0 1 1 1 2 5 |
|
50 // 1 1 0 0 0 1 |
|
51 // 2 1 0 0 0 1 |
|
52 // 3 0 0 0 1 1 |
|
53 // Any 0 0 0 1 1 |
|
54 class NodeDataArray : public CHeapObj<mtGC> { |
|
55 // The number of nodes. |
|
56 uint _num_column; |
|
57 // The number of nodes + 1 (for any node request) |
|
58 uint _num_row; |
|
59 // 2-dimension array that holds count of allocated / requested node index. |
|
60 size_t** _data; |
|
61 |
|
62 public: |
|
63 NodeDataArray(uint num_nodes); |
|
64 ~NodeDataArray(); |
|
65 |
|
66 // Create Stat result of hit count, requested count and hit rate. |
|
67 // The result is copied to the given result parameter. |
|
68 void create_hit_rate(Stat* result) const; |
|
69 // Create Stat result of hit count, requested count and hit rate of the given index. |
|
70 // The result is copied to the given result parameter. |
|
71 void create_hit_rate(Stat* result, uint req_index) const; |
|
72 // Return sum of the given index. |
|
73 size_t sum(uint req_index) const; |
|
74 // Increase at the request / allocated index. |
|
75 void increase(uint req_index, uint alloc_index); |
|
76 // Clear all data. |
|
77 void clear(); |
|
78 // Return current value of the given request / allocated index. |
|
79 size_t get(uint req_index, uint alloc_index); |
|
80 // Copy values of the given request index. |
|
81 void copy(uint req_index, size_t* stat); |
|
82 }; |
|
83 |
|
84 public: |
|
85 enum NodeDataItems { |
|
86 // Statistics of a new region allocation. |
|
87 NewRegionAlloc, |
|
88 // Statistics of object processing during copy to survivor region. |
|
89 LocalObjProcessAtCopyToSurv, |
|
90 NodeDataItemsSentinel |
|
91 }; |
|
92 |
|
93 private: |
|
94 const int* _node_ids; |
|
95 uint _num_node_ids; |
|
96 |
|
97 NodeDataArray* _node_data[NodeDataItemsSentinel]; |
|
98 |
|
99 void print_info(G1NUMAStats::NodeDataItems phase); |
|
100 |
|
101 void print_mutator_alloc_stat_debug(); |
|
102 |
|
103 public: |
|
104 G1NUMAStats(const int* node_ids, uint num_node_ids); |
|
105 ~G1NUMAStats(); |
|
106 |
|
107 void clear(G1NUMAStats::NodeDataItems phase); |
|
108 |
|
109 // Update the given phase of requested and allocated node index. |
|
110 void update(G1NUMAStats::NodeDataItems phase, uint requested_node_index, uint allocated_node_index); |
|
111 |
|
112 // Copy all allocated statistics of the given phase and requested node. |
|
113 // Precondition: allocated_stat should have same length of active nodes. |
|
114 void copy(G1NUMAStats::NodeDataItems phase, uint requested_node_index, size_t* allocated_stat); |
|
115 |
|
116 void print_statistics(); |
|
117 }; |
|
118 |
|
119 #endif // SHARE_VM_GC_G1_NODE_TIMES_HPP |