@@ -48,7 +48,7 @@ namespace snmalloc
4848 auto curr = *this ;
4949 while (!curr.is_empty ())
5050 {
51- auto next = get_next ();
51+ auto next = curr. get_next ();
5252
5353 f (curr.get_capability ());
5454
@@ -183,8 +183,7 @@ namespace snmalloc
183183 ParentRange::ConcurrencySafe,
184184 " Parent must be concurrency safe, as dealloc_range is called here on "
185185 " potentially another thread's state." );
186- auto new_epoch =
187- (epoch + 1 ) % NUM_EPOCHS;
186+ auto new_epoch = (epoch + 1 ) % NUM_EPOCHS;
188187 // Flush old index for all threads.
189188 auto curr = all_local.load (std::memory_order_acquire);
190189 while (curr != nullptr )
@@ -211,6 +210,9 @@ namespace snmalloc
211210 */
212211 static void process (PalTimerObject*)
213212 {
213+ #ifdef SNMALLOC_TRACING
214+ message<1024 >(" DecayRange::handle_decay_tick timer" );
215+ #endif
214216 handle_decay_tick ();
215217 }
216218
@@ -256,7 +258,14 @@ namespace snmalloc
256258 auto p = chunk_stack[slab_sizeclass][(epoch - e) % NUM_EPOCHS].pop ();
257259
258260 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
259267 return p;
268+ }
260269 }
261270 }
262271
@@ -272,14 +281,31 @@ namespace snmalloc
272281 result = parent->alloc_range (size);
273282 if (result != nullptr )
274283 {
284+ #ifdef SNMALLOC_TRACING
285+ message<1024 >(
286+ " DecayRange::alloc_range: returning from parent: {} on {}" ,
287+ address_cast (result), this );
288+ #endif
275289 return result;
276290 }
277291
278292 // We have run out of memory.
279293 // Try to free some memory to the parent.
294+ #ifdef SNMALLOC_TRACING
295+ message<1024 >(" DecayRange::handle_decay_tick OOM" );
296+ #endif
280297 handle_decay_tick ();
281298 }
282299
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+
283309 return result;
284310 }
285311
@@ -310,6 +336,11 @@ namespace snmalloc
310336
311337 auto slab_sizeclass = bits::next_pow2_bits (size) - MIN_CHUNK_BITS;
312338 // 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
313344 chunk_stack[slab_sizeclass][epoch].push (base);
314345 }
315346 };
0 commit comments