author | kbarrett |
Wed, 21 Aug 2019 18:42:30 -0400 | |
changeset 57828 | 35db8fba55f9 |
parent 53536 | 482109fae02b |
permissions | -rw-r--r-- |
51546 | 1 |
/* |
53536
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
2 |
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
51546 | 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_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP |
|
26 |
#define SHARE_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP |
|
27 |
||
57828
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
28 |
#include "gc/shared/oopStorageSet.hpp" |
51546 | 29 |
#include "gc/shared/weakProcessorPhases.hpp" |
30 |
#include "memory/allocation.hpp" |
|
31 |
#include "utilities/globalDefinitions.hpp" |
|
32 |
#include "utilities/ticks.hpp" |
|
33 |
||
34 |
template<typename T> class WorkerDataArray; |
|
35 |
||
36 |
class WeakProcessorPhaseTimes : public CHeapObj<mtGC> { |
|
53536
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
37 |
enum { |
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
38 |
DeadItems, |
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
39 |
TotalItems |
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
40 |
}; |
51546 | 41 |
uint _max_threads; |
42 |
uint _active_workers; |
|
43 |
||
44 |
// Total time for weak processor. |
|
45 |
double _total_time_sec; |
|
46 |
||
57828
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
47 |
// Total time and associated items for each serially processed phase. |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
48 |
static const uint phase_data_count = WeakProcessorPhases::serial_phase_count; |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
49 |
// +1 because serial_phase_count == 0 in some build configurations. |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
50 |
// Simpler to always allocate extra space than conditionalize. |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
51 |
double _phase_times_sec[phase_data_count + 1]; |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
52 |
size_t _phase_dead_items[phase_data_count + 1]; |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
53 |
size_t _phase_total_items[phase_data_count + 1]; |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
54 |
void reset_phase_data(); |
51546 | 55 |
|
57828
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
56 |
// Per-worker times and linked items. |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
57 |
static const uint worker_data_count = WeakProcessorPhases::oopstorage_phase_count; |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
58 |
WorkerDataArray<double>* _worker_data[worker_data_count]; |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
59 |
WorkerDataArray<size_t>* _worker_dead_items[worker_data_count]; |
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
60 |
WorkerDataArray<size_t>* _worker_total_items[worker_data_count]; |
51546 | 61 |
|
62 |
WorkerDataArray<double>* worker_data(WeakProcessorPhase phase) const; |
|
63 |
||
64 |
void log_st_phase(WeakProcessorPhase phase, uint indent) const; |
|
65 |
void log_mt_phase_summary(WeakProcessorPhase phase, uint indent) const; |
|
53536
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
66 |
template <typename T> |
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
67 |
void log_mt_phase_details(WorkerDataArray<T>* data, uint indent) const; |
51546 | 68 |
|
69 |
public: |
|
70 |
WeakProcessorPhaseTimes(uint max_threads); |
|
71 |
~WeakProcessorPhaseTimes(); |
|
72 |
||
73 |
uint max_threads() const; |
|
74 |
uint active_workers() const; |
|
75 |
void set_active_workers(uint n); |
|
76 |
||
77 |
double total_time_sec() const; |
|
78 |
double phase_time_sec(WeakProcessorPhase phase) const; |
|
79 |
double worker_time_sec(uint worker_id, WeakProcessorPhase phase) const; |
|
80 |
||
81 |
void record_total_time_sec(double time_sec); |
|
82 |
void record_phase_time_sec(WeakProcessorPhase phase, double time_sec); |
|
53536
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
83 |
void record_phase_items(WeakProcessorPhase phase, size_t num_dead, size_t num_total); |
51546 | 84 |
void record_worker_time_sec(uint worker_id, WeakProcessorPhase phase, double time_sec); |
53536
482109fae02b
8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents:
51546
diff
changeset
|
85 |
void record_worker_items(uint worker_id, WeakProcessorPhase phase, size_t num_dead, size_t num_total); |
51546 | 86 |
|
87 |
void reset(); |
|
88 |
||
89 |
void log_print(uint indent = 0) const; |
|
90 |
void log_print_phases(uint indent = 0) const; |
|
91 |
}; |
|
92 |
||
93 |
// Record total weak processor time and worker count in times. |
|
94 |
// Does nothing if times is NULL. |
|
95 |
class WeakProcessorTimeTracker : StackObj { |
|
96 |
WeakProcessorPhaseTimes* _times; |
|
97 |
Ticks _start_time; |
|
98 |
||
99 |
public: |
|
100 |
WeakProcessorTimeTracker(WeakProcessorPhaseTimes* times); |
|
101 |
~WeakProcessorTimeTracker(); |
|
102 |
}; |
|
103 |
||
104 |
// Record phase time contribution for the current thread in phase times. |
|
105 |
// Does nothing if phase times is NULL. |
|
106 |
class WeakProcessorPhaseTimeTracker : StackObj { |
|
107 |
private: |
|
108 |
WeakProcessorPhaseTimes* _times; |
|
109 |
WeakProcessorPhase _phase; |
|
110 |
uint _worker_id; |
|
111 |
Ticks _start_time; |
|
112 |
||
113 |
public: |
|
114 |
// For tracking serial phase times. |
|
115 |
// Precondition: WeakProcessorPhases::is_serial(phase) |
|
116 |
WeakProcessorPhaseTimeTracker(WeakProcessorPhaseTimes* times, |
|
117 |
WeakProcessorPhase phase); |
|
118 |
||
119 |
// For tracking possibly parallel phase times (even if processed by |
|
120 |
// only one thread). |
|
57828
35db8fba55f9
8227054: ServiceThread needs to know about all OopStorage objects
kbarrett
parents:
53536
diff
changeset
|
121 |
// Precondition: WeakProcessorPhases::is_oopstorage(phase) |
51546 | 122 |
// Precondition: worker_id < times->max_threads(). |
123 |
WeakProcessorPhaseTimeTracker(WeakProcessorPhaseTimes* times, |
|
124 |
WeakProcessorPhase phase, |
|
125 |
uint worker_id); |
|
126 |
||
127 |
~WeakProcessorPhaseTimeTracker(); |
|
128 |
}; |
|
129 |
||
130 |
#endif // SHARE_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP |