@@ -70,11 +70,11 @@ class TAlignedPagePoolImpl {
70
70
71
71
explicit TAlignedPagePoolImpl (const TSourceLocation& location,
72
72
const TAlignedPagePoolCounters& counters = TAlignedPagePoolCounters())
73
- : Counters (counters)
74
- , DebugInfo (location)
73
+ : Counters_ (counters)
74
+ , DebugInfo_ (location)
75
75
{
76
- if (Counters .PoolsCntr ) {
77
- ++(*Counters .PoolsCntr );
76
+ if (Counters_ .PoolsCntr ) {
77
+ ++(*Counters_ .PoolsCntr );
78
78
}
79
79
}
80
80
@@ -87,15 +87,15 @@ class TAlignedPagePoolImpl {
87
87
~TAlignedPagePoolImpl ();
88
88
89
89
inline size_t GetAllocated () const noexcept {
90
- return TotalAllocated ;
90
+ return TotalAllocated_ ;
91
91
}
92
92
93
93
inline size_t GetUsed () const noexcept {
94
- return TotalAllocated - GetFreePageCount () * POOL_PAGE_SIZE;
94
+ return TotalAllocated_ - GetFreePageCount () * POOL_PAGE_SIZE;
95
95
}
96
96
97
97
inline size_t GetFreePageCount () const noexcept {
98
- return FreePages .size ();
98
+ return FreePages_ .size ();
99
99
}
100
100
101
101
static inline const void * GetPageStart (const void * addr) noexcept {
@@ -111,71 +111,71 @@ class TAlignedPagePoolImpl {
111
111
void ReturnPage (void * addr) noexcept ;
112
112
113
113
void Swap (TAlignedPagePoolImpl& other) {
114
- DoSwap (FreePages , other.FreePages );
115
- DoSwap (AllPages , other.AllPages );
116
- DoSwap (ActiveBlocks , other.ActiveBlocks );
117
- DoSwap (TotalAllocated , other.TotalAllocated );
118
- DoSwap (PeakAllocated , other.PeakAllocated );
119
- DoSwap (PeakUsed , other.PeakUsed );
120
- DoSwap (Limit , other.Limit );
121
- DoSwap (AllocCount , other.AllocCount );
122
- DoSwap (PageAllocCount , other.PageAllocCount );
123
- DoSwap (PageHitCount , other.PageHitCount );
124
- DoSwap (PageGlobalHitCount , other.PageGlobalHitCount );
125
- DoSwap (PageMissCount , other.PageMissCount );
126
- DoSwap (OffloadedAllocCount , other.OffloadedAllocCount );
127
- DoSwap (OffloadedBytes , other.OffloadedBytes );
128
- DoSwap (OffloadedActiveBytes , other.OffloadedActiveBytes );
129
- DoSwap (Counters , other.Counters );
130
- DoSwap (CheckLostMem , other.CheckLostMem );
131
- DoSwap (AllocNotifyCallback , other.AllocNotifyCallback );
132
- DoSwap (IncreaseMemoryLimitCallback , other.IncreaseMemoryLimitCallback );
114
+ DoSwap (FreePages_ , other.FreePages_ );
115
+ DoSwap (AllPages_ , other.AllPages_ );
116
+ DoSwap (ActiveBlocks_ , other.ActiveBlocks_ );
117
+ DoSwap (TotalAllocated_ , other.TotalAllocated_ );
118
+ DoSwap (PeakAllocated_ , other.PeakAllocated_ );
119
+ DoSwap (PeakUsed_ , other.PeakUsed_ );
120
+ DoSwap (Limit_ , other.Limit_ );
121
+ DoSwap (AllocCount_ , other.AllocCount_ );
122
+ DoSwap (PageAllocCount_ , other.PageAllocCount_ );
123
+ DoSwap (PageHitCount_ , other.PageHitCount_ );
124
+ DoSwap (PageGlobalHitCount_ , other.PageGlobalHitCount_ );
125
+ DoSwap (PageMissCount_ , other.PageMissCount_ );
126
+ DoSwap (OffloadedAllocCount_ , other.OffloadedAllocCount_ );
127
+ DoSwap (OffloadedBytes_ , other.OffloadedBytes_ );
128
+ DoSwap (OffloadedActiveBytes_ , other.OffloadedActiveBytes_ );
129
+ DoSwap (Counters_ , other.Counters_ );
130
+ DoSwap (CheckLostMem_ , other.CheckLostMem_ );
131
+ DoSwap (AllocNotifyCallback_ , other.AllocNotifyCallback_ );
132
+ DoSwap (IncreaseMemoryLimitCallback_ , other.IncreaseMemoryLimitCallback_ );
133
133
}
134
134
135
135
void PrintStat (size_t usedPages, IOutputStream& out) const ;
136
136
137
137
TString GetDebugInfo () const {
138
- return ToString (DebugInfo );
138
+ return ToString (DebugInfo_ );
139
139
}
140
140
141
141
void * GetBlock (size_t size);
142
142
143
143
void ReturnBlock (void * ptr, size_t size) noexcept ;
144
144
145
145
size_t GetPeakAllocated () const noexcept {
146
- return PeakAllocated ;
146
+ return PeakAllocated_ ;
147
147
}
148
148
149
149
size_t GetPeakUsed () const noexcept {
150
- return PeakUsed ;
150
+ return PeakUsed_ ;
151
151
}
152
152
153
153
ui64 GetAllocCount () const noexcept {
154
- return AllocCount ;
154
+ return AllocCount_ ;
155
155
}
156
156
157
157
ui64 GetPageAllocCount () const noexcept {
158
- return PageAllocCount ;
158
+ return PageAllocCount_ ;
159
159
}
160
160
161
161
ui64 GetPageHitCount () const noexcept {
162
- return PageHitCount ;
162
+ return PageHitCount_ ;
163
163
}
164
164
165
165
ui64 GetPageGlobalHitCount () const noexcept {
166
- return PageGlobalHitCount ;
166
+ return PageGlobalHitCount_ ;
167
167
}
168
168
169
169
ui64 GetPageMissCount () const noexcept {
170
- return PageMissCount ;
170
+ return PageMissCount_ ;
171
171
}
172
172
173
173
ui64 GetOffloadedAllocCount () const noexcept {
174
- return OffloadedAllocCount ;
174
+ return OffloadedAllocCount_ ;
175
175
}
176
176
177
177
ui64 GetOffloadedBytes () const noexcept {
178
- return OffloadedBytes ;
178
+ return OffloadedBytes_ ;
179
179
}
180
180
181
181
void OffloadAlloc (ui64 size);
@@ -186,49 +186,49 @@ class TAlignedPagePoolImpl {
186
186
static ui64 GetGlobalPagePoolSize ();
187
187
188
188
ui64 GetLimit () const noexcept {
189
- return Limit ;
189
+ return Limit_ ;
190
190
}
191
191
192
192
void SetLimit (size_t limit) noexcept {
193
- Limit = limit;
193
+ Limit_ = limit;
194
194
}
195
195
196
196
void ReleaseFreePages ();
197
197
198
198
void DisableStrictAllocationCheck () noexcept {
199
- CheckLostMem = false ;
199
+ CheckLostMem_ = false ;
200
200
}
201
201
202
202
using TAllocNotifyCallback = std::function<void ()>;
203
203
void SetAllocNotifyCallback (TAllocNotifyCallback&& callback, ui64 notifyBytes = 0 ) {
204
- AllocNotifyCallback = std::move (callback);
205
- AllocNotifyBytes = notifyBytes;
206
- AllocNotifyCurrentBytes = 0 ;
204
+ AllocNotifyCallback_ = std::move (callback);
205
+ AllocNotifyBytes_ = notifyBytes;
206
+ AllocNotifyCurrentBytes_ = 0 ;
207
207
}
208
208
209
209
using TIncreaseMemoryLimitCallback = std::function<void (ui64 currentLimit, ui64 required)>;
210
210
211
211
void SetIncreaseMemoryLimitCallback (TIncreaseMemoryLimitCallback&& callback) {
212
- IncreaseMemoryLimitCallback = std::move (callback);
212
+ IncreaseMemoryLimitCallback_ = std::move (callback);
213
213
}
214
214
215
215
static void ResetGlobalsUT ();
216
216
217
217
void SetMaximumLimitValueReached (bool isReached) noexcept {
218
- IsMaximumLimitValueReached = isReached;
218
+ IsMaximumLimitValueReached_ = isReached;
219
219
}
220
220
221
221
bool GetMaximumLimitValueReached () const noexcept {
222
- return IsMaximumLimitValueReached ;
222
+ return IsMaximumLimitValueReached_ ;
223
223
}
224
224
225
225
bool IsMemoryYellowZoneEnabled () const noexcept {
226
- return IsMemoryYellowZoneReached ;
226
+ return IsMemoryYellowZoneReached_ ;
227
227
}
228
228
229
229
void ForcefullySetMemoryYellowZone (bool isEnabled) noexcept {
230
- IsMemoryYellowZoneReached = isEnabled;
231
- IsMemoryYellowZoneForcefullyChanged = true ;
230
+ IsMemoryYellowZoneReached_ = isEnabled;
231
+ IsMemoryYellowZoneForcefullyChanged_ = true ;
232
232
}
233
233
234
234
#if defined(ALLOW_DEFAULT_ALLOCATOR)
@@ -244,8 +244,8 @@ class TAlignedPagePoolImpl {
244
244
void Free (void * ptr, size_t size) noexcept ;
245
245
246
246
void UpdatePeaks () {
247
- PeakAllocated = Max (PeakAllocated , GetAllocated ());
248
- PeakUsed = Max (PeakUsed , GetUsed ());
247
+ PeakAllocated_ = Max (PeakAllocated_ , GetAllocated ());
248
+ PeakUsed_ = Max (PeakUsed_ , GetUsed ());
249
249
250
250
UpdateMemoryYellowZone ();
251
251
}
@@ -258,49 +258,49 @@ class TAlignedPagePoolImpl {
258
258
259
259
void * GetPageImpl ();
260
260
protected:
261
- std::stack<void *, std::vector<void *>> FreePages ;
262
- std::unordered_set<void *> AllPages ;
263
- std::unordered_map<void *, size_t > ActiveBlocks ;
264
- size_t TotalAllocated = 0 ;
265
- size_t PeakAllocated = 0 ;
266
- size_t PeakUsed = 0 ;
267
- size_t Limit = 0 ;
268
-
269
- ui64 AllocCount = 0 ;
270
- ui64 PageAllocCount = 0 ;
271
- ui64 PageHitCount = 0 ;
272
- ui64 PageGlobalHitCount = 0 ;
273
- ui64 PageMissCount = 0 ;
274
-
275
- ui64 OffloadedAllocCount = 0 ;
276
- ui64 OffloadedBytes = 0 ;
277
- ui64 OffloadedActiveBytes = 0 ;
278
-
279
- TAlignedPagePoolCounters Counters ;
280
- bool CheckLostMem = true ;
281
-
282
- TAllocNotifyCallback AllocNotifyCallback ;
283
- ui64 AllocNotifyBytes = 0 ;
284
- ui64 AllocNotifyCurrentBytes = 0 ;
285
-
286
- TIncreaseMemoryLimitCallback IncreaseMemoryLimitCallback ;
287
- const TSourceLocation DebugInfo ;
261
+ std::stack<void *, std::vector<void *>> FreePages_ ;
262
+ std::unordered_set<void *> AllPages_ ;
263
+ std::unordered_map<void *, size_t > ActiveBlocks_ ;
264
+ size_t TotalAllocated_ = 0 ;
265
+ size_t PeakAllocated_ = 0 ;
266
+ size_t PeakUsed_ = 0 ;
267
+ size_t Limit_ = 0 ;
268
+
269
+ ui64 AllocCount_ = 0 ;
270
+ ui64 PageAllocCount_ = 0 ;
271
+ ui64 PageHitCount_ = 0 ;
272
+ ui64 PageGlobalHitCount_ = 0 ;
273
+ ui64 PageMissCount_ = 0 ;
274
+
275
+ ui64 OffloadedAllocCount_ = 0 ;
276
+ ui64 OffloadedBytes_ = 0 ;
277
+ ui64 OffloadedActiveBytes_ = 0 ;
278
+
279
+ TAlignedPagePoolCounters Counters_ ;
280
+ bool CheckLostMem_ = true ;
281
+
282
+ TAllocNotifyCallback AllocNotifyCallback_ ;
283
+ ui64 AllocNotifyBytes_ = 0 ;
284
+ ui64 AllocNotifyCurrentBytes_ = 0 ;
285
+
286
+ TIncreaseMemoryLimitCallback IncreaseMemoryLimitCallback_ ;
287
+ const TSourceLocation DebugInfo_ ;
288
288
289
289
// Indicates when memory limit is almost reached.
290
- bool IsMemoryYellowZoneReached = false ;
290
+ bool IsMemoryYellowZoneReached_ = false ;
291
291
// Indicates that memory yellow zone was enabled or disabled forcefully.
292
292
// If the value of this variable is true, then the limits specified below will not be applied and
293
293
// changing the value can only be done manually.
294
- bool IsMemoryYellowZoneForcefullyChanged = false ;
294
+ bool IsMemoryYellowZoneForcefullyChanged_ = false ;
295
295
// This theshold is used to determine is memory limit is almost reached.
296
296
// If TIncreaseMemoryLimitCallback is set this thresholds should be ignored.
297
297
// The yellow zone turns on when memory consumption reaches 80% and turns off when consumption drops below 50%.
298
- const ui8 EnableMemoryYellowZoneThreshold = 80 ;
299
- const ui8 DisableMemoryYellowZoneThreshold = 50 ;
298
+ const ui8 EnableMemoryYellowZoneThreshold_ = 80 ;
299
+ const ui8 DisableMemoryYellowZoneThreshold_ = 50 ;
300
300
301
301
// This flag indicates that value of memory limit reached it's maximum.
302
302
// Next TryIncreaseLimit call most likely will return false.
303
- bool IsMaximumLimitValueReached = false ;
303
+ bool IsMaximumLimitValueReached_ = false ;
304
304
};
305
305
306
306
using TAlignedPagePool = TAlignedPagePoolImpl<>;
0 commit comments