-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathConcurrentSweepStats.hpp
180 lines (160 loc) · 6.27 KB
/
ConcurrentSweepStats.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*******************************************************************************
* Copyright IBM Corp. and others 1991
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
#if !defined(CONCURRENTSWEEPSTATS_HPP_)
#define CONCURRENTSWEEPSTATS_HPP_
#include "omrcfg.h"
#include "omrcomp.h"
#include "modronbase.h"
#if defined(OMR_GC_CONCURRENT_SWEEP)
#include "Base.hpp"
#include "Debug.hpp"
enum {
concurrentsweep_mode_off = 0,
concurrentsweep_mode_stw_find_minimum_free_size,
concurrentsweep_mode_on,
concurrentsweep_mode_completing_sweep_phase_concurrently,
concurrentsweep_mode_completed_sweep_phase_concurrently,
concurrentsweep_mode_stw_complete_sweep
};
/**
* Statistics for concurrent sweep operations.
*/
class MM_ConcurrentSweepStats : public MM_Base
{
private:
protected:
public:
/**
* General concurrent statistics.
* @{
*/
volatile uintptr_t _mode; /**< Concurrent sweep phase of operation */
uintptr_t _totalChunkCount; /**< Total number of chunks included in the concurrent sweep calculation */
volatile uintptr_t _totalChunkSweptCount; /**< Total number of chunks that have been swept through concurrent sweep */
/**
* @}
*/
/**
* STW Find minimum free sized entry sweep statistics.
* @{
*/
uintptr_t _minimumFreeEntryBytesSwept; /**< Total bytes swept in heap while finding minimum free sized entry */
uintptr_t _minimumFreeEntryBytesConnected; /**< Total bytes connected in heap while finding minimum free sized entry */
/**
* @}
*/
/**
* Concurrent completion of sweep phase statistics.
* @{
*/
uint64_t _concurrentCompleteSweepTimeStart; /**< Start timestamp for concurrent completion of sweep phase */
uint64_t _concurrentCompleteSweepTimeEnd; /**< End timestamp for concurrent completion of sweep phase */
volatile uintptr_t _concurrentCompleteSweepBytesSwept; /**< Bytes swept during the concurrent completion of sweep phase */
/**
* @}
*/
/**
* STW completion of concurrent sweep statistics.
* @{
*/
uint64_t _completeSweepPhaseTimeStart; /**< Start timestamp for completion of sweep phase */
uint64_t _completeSweepPhaseTimeEnd; /**< End timestamp for completion of sweep phase */
volatile uintptr_t _completeSweepPhaseBytesSwept; /**< Bytes swept during the completion of sweep phase */
uint64_t _completeConnectPhaseTimeStart; /**< Start timestamp for completion of connect phase */
uint64_t _completeConnectPhaseTimeEnd; /**< End timestamp for completion of connect phase */
uintptr_t _completeConnectPhaseBytesConnected; /**< Bytes connected during the completion of connect phase */
/**
* @}
*/
/**
* Force the concurrent sweep mode into a particular state.
* @note This routine should only be used for initialization or clearing.
* @sa switchMode(uintptr_t, uintptr_t)
*/
MMINLINE void setMode(uintptr_t mode) {
_mode = mode;
}
/**
* Move the concurrent sweep mode from one type to another.
*/
MMINLINE void switchMode(uintptr_t oldMode, uintptr_t newMode) {
assume0(_mode == oldMode);
_mode = newMode;
}
/**
* Determine whether concurrent sweeping activity is possible this round.
* @return true if concurrent sweep is active, false otherwise.
*/
MMINLINE bool isConcurrentSweepActive() { return concurrentsweep_mode_off != _mode; }
/**
* Determine whether a concurrent completion of the sweep phase can be started or is already in progress.
* @return true if the work can or has been started, false if it cannot or has been completed.
*/
MMINLINE bool canCompleteSweepConcurrently() { return (concurrentsweep_mode_on <= _mode) && (concurrentsweep_mode_completed_sweep_phase_concurrently > _mode); }
/**
* Determine if a concurrent completion of the sweep phase is in progress.
* @return true if the work is in progress, false otherwise.
*/
MMINLINE bool isCompletingSweepConcurrently() { return concurrentsweep_mode_completing_sweep_phase_concurrently == _mode; }
/**
* Determine whether the concurrent completion of the sweep phase is done.
* @return true if the work has completed, false otherwise.
*/
MMINLINE bool hasCompletedSweepConcurrently() { return concurrentsweep_mode_completed_sweep_phase_concurrently == _mode; }
/**
* Reset all statistics to starting values.
*/
MMINLINE void clear() {
_totalChunkCount = 0;
_totalChunkSweptCount = 0;
_minimumFreeEntryBytesSwept = 0;
_minimumFreeEntryBytesConnected = 0;
_concurrentCompleteSweepTimeStart = 0;
_concurrentCompleteSweepTimeEnd = 0;
_concurrentCompleteSweepBytesSwept = 0;
_completeSweepPhaseTimeStart = 0;
_completeSweepPhaseTimeEnd = 0;
_completeSweepPhaseBytesSwept = 0;
_completeConnectPhaseTimeStart = 0;
_completeConnectPhaseTimeEnd = 0;
_completeConnectPhaseBytesConnected = 0;
}
MM_ConcurrentSweepStats() :
MM_Base(),
_mode(concurrentsweep_mode_off),
_totalChunkCount(0),
_totalChunkSweptCount(0),
_minimumFreeEntryBytesSwept(0),
_minimumFreeEntryBytesConnected(0),
_concurrentCompleteSweepTimeStart(0),
_concurrentCompleteSweepTimeEnd(0),
_concurrentCompleteSweepBytesSwept(0),
_completeSweepPhaseTimeStart(0),
_completeSweepPhaseTimeEnd(0),
_completeSweepPhaseBytesSwept(0),
_completeConnectPhaseTimeStart(0),
_completeConnectPhaseTimeEnd(0),
_completeConnectPhaseBytesConnected(0)
{}
};
#endif /* OMR_GC_CONCURRENT_SWEEP */
#endif /* CONCURRENTSWEEPSTATS_HPP_ */