MCPcopy Create free account
hub / github.com/catboost/catboost / PutBlocksToGlobalFreeList

Function PutBlocksToGlobalFreeList

library/cpp/lfalloc/lf_allocX64.h:980–1002  ·  view source on GitHub ↗

add several blocks to global free list

Source from the content-addressed store, hash-verified

978
979// add several blocks to global free list
980static Y_FORCE_INLINE void PutBlocksToGlobalFreeList(ptrdiff_t nSizeIdx, char** buf, int count) {
981 for (int startIdx = 0; startIdx < count;) {
982 TFreeListGroup* g = (TFreeListGroup*)blockFreeList.Alloc();
983 Y_ASSERT_NOBT(sizeof(TFreeListGroup) == nSizeIdxToSize[FREE_LIST_GROUP_SIZEIDX]);
984 if (!g) {
985 g = (TFreeListGroup*)LFAllocNoCache(FREE_LIST_GROUP_SIZEIDX, NO_MEM_DEFRAG);
986 }
987
988 int groupSize = count - startIdx;
989 if (groupSize > FL_GROUP_SIZE)
990 groupSize = FL_GROUP_SIZE;
991 for (int i = 0; i < groupSize; ++i)
992 g->Ptrs[i] = buf[startIdx + i];
993 for (int i = groupSize; i < FL_GROUP_SIZE; ++i)
994 g->Ptrs[i] = nullptr;
995
996 // add free group to the global list
997 TLFAllocFreeList& fl = globalFreeLists[nSizeIdx];
998 fl.Free(g);
999
1000 startIdx += groupSize;
1001 }
1002}
1003
1004//////////////////////////////////////////////////////////////////////////
1005static TAtomic GlobalCounters[CT_MAX];

Callers 2

LFFreeFunction · 0.85

Calls 3

LFAllocNoCacheFunction · 0.85
AllocMethod · 0.45
FreeMethod · 0.45

Tested by

no test coverage detected