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

Method ReleaseToCentralCache

BeefTools/BeefMem/gperftools/src/thread_cache.cc:215–233  ·  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

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