MCPcopy Create free account
hub / github.com/beefytech/Beef / ReleaseToCentralCache

Method ReleaseToCentralCache

BeefRT/gperftools/src/thread_cache.cc:218–236  ·  view source on GitHub ↗

Remove some objects of class "cl" from thread heap and add to central cache

Source from the content-addressed store, hash-verified

216
217// Remove some objects of class "cl" from thread heap and add to central cache
218void ThreadCache::ReleaseToCentralCache(FreeList* src, size_t cl, int N) {
219 ASSERT(src == &list_[cl]);
220 if (N > src->length()) N = src->length();
221 size_t delta_bytes = N * Static::sizemap()->ByteSizeForClass(cl);
222
223 // We return prepackaged chains of the correct size to the central cache.
224 // TODO: Use the same format internally in the thread caches?
225 int batch_size = Static::sizemap()->num_objects_to_move(cl);
226 while (N > batch_size) {
227 void *tail, *head;
228 src->PopRange(batch_size, &head, &tail);
229 Static::central_cache()[cl].InsertRange(head, tail, batch_size);
230 N -= batch_size;
231 }
232 void *tail, *head;
233 src->PopRange(N, &head, &tail);
234 Static::central_cache()[cl].InsertRange(head, tail, N);
235 size_ -= delta_bytes;
236}
237
238// Release idle memory to the central cache
239void ThreadCache::Scavenge() {

Callers

nothing calls this directly

Calls 5

lengthMethod · 0.45
ByteSizeForClassMethod · 0.45
num_objects_to_moveMethod · 0.45
PopRangeMethod · 0.45
InsertRangeMethod · 0.45

Tested by

no test coverage detected