@@ -48,7 +48,7 @@ namespace snmalloc
48
48
auto curr = *this ;
49
49
while (!curr.is_empty ())
50
50
{
51
- auto next = get_next ();
51
+ auto next = curr. get_next ();
52
52
53
53
f (curr.get_capability ());
54
54
@@ -183,8 +183,7 @@ namespace snmalloc
183
183
ParentRange::ConcurrencySafe,
184
184
" Parent must be concurrency safe, as dealloc_range is called here on "
185
185
" potentially another thread's state." );
186
- auto new_epoch =
187
- (epoch + 1 ) % NUM_EPOCHS;
186
+ auto new_epoch = (epoch + 1 ) % NUM_EPOCHS;
188
187
// Flush old index for all threads.
189
188
auto curr = all_local.load (std::memory_order_acquire);
190
189
while (curr != nullptr )
@@ -211,6 +210,9 @@ namespace snmalloc
211
210
*/
212
211
static void process (PalTimerObject*)
213
212
{
213
+ #ifdef SNMALLOC_TRACING
214
+ message<1024 >(" DecayRange::handle_decay_tick timer" );
215
+ #endif
214
216
handle_decay_tick ();
215
217
}
216
218
@@ -256,7 +258,14 @@ namespace snmalloc
256
258
auto p = chunk_stack[slab_sizeclass][(epoch - e) % NUM_EPOCHS].pop ();
257
259
258
260
if (p != nullptr )
261
+ {
262
+ #ifdef SNMALLOC_TRACING
263
+ message<1024 >(
264
+ " DecayRange::alloc_range: returning from local cache: {} on {}" ,
265
+ address_cast (p), this );
266
+ #endif
259
267
return p;
268
+ }
260
269
}
261
270
}
262
271
@@ -272,14 +281,31 @@ namespace snmalloc
272
281
result = parent->alloc_range (size);
273
282
if (result != nullptr )
274
283
{
284
+ #ifdef SNMALLOC_TRACING
285
+ message<1024 >(
286
+ " DecayRange::alloc_range: returning from parent: {} on {}" ,
287
+ address_cast (result), this );
288
+ #endif
275
289
return result;
276
290
}
277
291
278
292
// We have run out of memory.
279
293
// Try to free some memory to the parent.
294
+ #ifdef SNMALLOC_TRACING
295
+ message<1024 >(" DecayRange::handle_decay_tick OOM" );
296
+ #endif
280
297
handle_decay_tick ();
281
298
}
282
299
300
+ // Last try.
301
+ result = parent->alloc_range (size);
302
+
303
+ #ifdef SNMALLOC_TRACING
304
+ message<1024 >(
305
+ " DecayRange::alloc_range: returning from parent last try: {} on {}" ,
306
+ address_cast (result), this );
307
+ #endif
308
+
283
309
return result;
284
310
}
285
311
@@ -310,6 +336,11 @@ namespace snmalloc
310
336
311
337
auto slab_sizeclass = bits::next_pow2_bits (size) - MIN_CHUNK_BITS;
312
338
// Add to local cache.
339
+ #ifdef SNMALLOC_TRACING
340
+ message<1024 >(
341
+ " DecayRange::dealloc_range: returning to local cache: {} on {}" ,
342
+ address_cast (base), this );
343
+ #endif
313
344
chunk_stack[slab_sizeclass][epoch].push (base);
314
345
}
315
346
};
0 commit comments