add several blocks to global free list
| 978 | |
| 979 | // add several blocks to global free list |
| 980 | static 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 | ////////////////////////////////////////////////////////////////////////// |
| 1005 | static TAtomic GlobalCounters[CT_MAX]; |
no test coverage detected