MCPcopy Create free account
hub / github.com/devosoft/avida / ReleaseToCentralCache

Method ReleaseToCentralCache

libs/tcmalloc-1.4/src/thread_cache.cc:213–232  ·  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

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected