|
1 /* |
|
2 * Copyright (c) 2018, 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_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP |
|
26 #define SHARE_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP |
|
27 |
|
28 #include "gc/shared/weakProcessorPhases.hpp" |
|
29 #include "memory/allocation.hpp" |
|
30 #include "utilities/globalDefinitions.hpp" |
|
31 #include "utilities/ticks.hpp" |
|
32 |
|
33 template<typename T> class WorkerDataArray; |
|
34 |
|
35 class WeakProcessorPhaseTimes : public CHeapObj<mtGC> { |
|
36 uint _max_threads; |
|
37 uint _active_workers; |
|
38 |
|
39 // Total time for weak processor. |
|
40 double _total_time_sec; |
|
41 |
|
42 // Total time for each serially processed phase. Entries for phases |
|
43 // processed by multiple threads are unused, as are entries for |
|
44 // unexecuted phases. |
|
45 double _phase_times_sec[WeakProcessorPhases::phase_count]; |
|
46 |
|
47 // Per-worker times, if multiple threads used and the phase was executed. |
|
48 WorkerDataArray<double>* _worker_phase_times_sec[WeakProcessorPhases::oop_storage_phase_count]; |
|
49 |
|
50 WorkerDataArray<double>* worker_data(WeakProcessorPhase phase) const; |
|
51 |
|
52 void log_st_phase(WeakProcessorPhase phase, uint indent) const; |
|
53 void log_mt_phase_summary(WeakProcessorPhase phase, uint indent) const; |
|
54 void log_mt_phase_details(WeakProcessorPhase phase, uint indent) const; |
|
55 |
|
56 public: |
|
57 WeakProcessorPhaseTimes(uint max_threads); |
|
58 ~WeakProcessorPhaseTimes(); |
|
59 |
|
60 uint max_threads() const; |
|
61 uint active_workers() const; |
|
62 void set_active_workers(uint n); |
|
63 |
|
64 double total_time_sec() const; |
|
65 double phase_time_sec(WeakProcessorPhase phase) const; |
|
66 double worker_time_sec(uint worker_id, WeakProcessorPhase phase) const; |
|
67 |
|
68 void record_total_time_sec(double time_sec); |
|
69 void record_phase_time_sec(WeakProcessorPhase phase, double time_sec); |
|
70 void record_worker_time_sec(uint worker_id, WeakProcessorPhase phase, double time_sec); |
|
71 |
|
72 void reset(); |
|
73 |
|
74 void log_print(uint indent = 0) const; |
|
75 void log_print_phases(uint indent = 0) const; |
|
76 }; |
|
77 |
|
78 // Record total weak processor time and worker count in times. |
|
79 // Does nothing if times is NULL. |
|
80 class WeakProcessorTimeTracker : StackObj { |
|
81 WeakProcessorPhaseTimes* _times; |
|
82 Ticks _start_time; |
|
83 |
|
84 public: |
|
85 WeakProcessorTimeTracker(WeakProcessorPhaseTimes* times); |
|
86 ~WeakProcessorTimeTracker(); |
|
87 }; |
|
88 |
|
89 // Record phase time contribution for the current thread in phase times. |
|
90 // Does nothing if phase times is NULL. |
|
91 class WeakProcessorPhaseTimeTracker : StackObj { |
|
92 private: |
|
93 WeakProcessorPhaseTimes* _times; |
|
94 WeakProcessorPhase _phase; |
|
95 uint _worker_id; |
|
96 Ticks _start_time; |
|
97 |
|
98 public: |
|
99 // For tracking serial phase times. |
|
100 // Precondition: WeakProcessorPhases::is_serial(phase) |
|
101 WeakProcessorPhaseTimeTracker(WeakProcessorPhaseTimes* times, |
|
102 WeakProcessorPhase phase); |
|
103 |
|
104 // For tracking possibly parallel phase times (even if processed by |
|
105 // only one thread). |
|
106 // Precondition: WeakProcessorPhases::is_oop_storage(phase) |
|
107 // Precondition: worker_id < times->max_threads(). |
|
108 WeakProcessorPhaseTimeTracker(WeakProcessorPhaseTimes* times, |
|
109 WeakProcessorPhase phase, |
|
110 uint worker_id); |
|
111 |
|
112 ~WeakProcessorPhaseTimeTracker(); |
|
113 }; |
|
114 |
|
115 #endif // SHARE_GC_SHARED_WEAKPROCESSORPHASETIMES_HPP |