Lines Matching defs:Sci
82 SizeClassInfo *Sci = getSizeClassInfo(I);
83 Sci->RandState = getRandomU32(&Seed);
84 // Sci->MaxRegionIndex is already initialized to 0.
85 Sci->MinRegionIndex = NumRegions;
86 Sci->ReleaseInfo.LastReleaseAtNs = Time;
106 SizeClassInfo *Sci = getSizeClassInfo(I);
107 ScopedLock L(Sci->Mutex);
108 if (Sci->MinRegionIndex < MinRegionIndex)
109 MinRegionIndex = Sci->MinRegionIndex;
110 if (Sci->MaxRegionIndex > MaxRegionIndex)
111 MaxRegionIndex = Sci->MaxRegionIndex;
112 *Sci = {};
130 SizeClassInfo *Sci = getSizeClassInfo(I);
131 ScopedLock L1(Sci->Mutex);
133 for (BatchGroupT &BG : Sci->FreeListInfo.BlockList) {
141 DCHECK_EQ(TotalBlocks, Sci->AllocatedUser / BlockSize);
142 DCHECK_EQ(Sci->FreeListInfo.PushedBlocks, Sci->FreeListInfo.PoppedBlocks);
145 SizeClassInfo *Sci = getSizeClassInfo(SizeClassMap::BatchClassId);
146 ScopedLock L1(Sci->Mutex);
148 for (BatchGroupT &BG : Sci->FreeListInfo.BlockList) {
161 Sci->AllocatedUser / BlockSize);
163 Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks;
197 SizeClassInfo *Sci = getSizeClassInfo(ClassId);
198 ScopedLock L(Sci->Mutex);
200 u16 PopCount = popBlocksImpl(C, ClassId, Sci, ToArray, MaxBlockCount);
202 if (UNLIKELY(!populateFreeList(C, ClassId, Sci)))
204 PopCount = popBlocksImpl(C, ClassId, Sci, ToArray, MaxBlockCount);
216 SizeClassInfo *Sci = getSizeClassInfo(ClassId);
218 ScopedLock L(Sci->Mutex);
219 pushBatchClassBlocks(Sci, Array, Size);
242 ScopedLock L(Sci->Mutex);
243 pushBlocksImpl(C, ClassId, Sci, Array, Size, SameGroup);
272 SizeClassInfo *Sci = getSizeClassInfo(I);
276 Sci->Mutex.assertHeld();
277 if (Sci->MinRegionIndex < MinRegionIndex)
278 MinRegionIndex = Sci->MinRegionIndex;
279 if (Sci->MaxRegionIndex > MaxRegionIndex)
280 MaxRegionIndex = Sci->MaxRegionIndex;
304 SizeClassInfo *Sci = getSizeClassInfo(I);
305 ScopedLock L(Sci->Mutex);
306 TotalMapped += Sci->AllocatedUser;
307 PoppedBlocks += Sci->FreeListInfo.PoppedBlocks;
308 PushedBlocks += Sci->FreeListInfo.PushedBlocks;
314 SizeClassInfo *Sci = getSizeClassInfo(I);
315 ScopedLock L(Sci->Mutex);
316 getStats(Str, I, Sci);
326 SizeClassInfo *Sci = getSizeClassInfo(I);
327 ScopedLock L(Sci->Mutex);
328 getSizeClassFragmentationInfo(Sci, I, Str);
351 SizeClassInfo *Sci = getSizeClassInfo(ClassId);
354 ScopedLock L(Sci->Mutex);
355 return releaseToOSMaybe(Sci, ClassId, ReleaseType);
363 SizeClassInfo *Sci = getSizeClassInfo(I);
364 ScopedLock L(Sci->Mutex);
365 TotalReleasedBytes += releaseToOSMaybe(Sci, I, ReleaseType);
452 uptr allocateRegion(SizeClassInfo *Sci, uptr ClassId) REQUIRES(Sci->Mutex) {
463 // Sci->Mutex is held by the caller, updating the Min/Max is safe.
465 if (RegionIndex < Sci->MinRegionIndex)
466 Sci->MinRegionIndex = RegionIndex;
467 if (RegionIndex > Sci->MaxRegionIndex)
468 Sci->MaxRegionIndex = RegionIndex;
480 void pushBatchClassBlocks(SizeClassInfo *Sci, CompactPtrT *Array, u32 Size)
481 REQUIRES(Sci->Mutex) {
482 DCHECK_EQ(Sci, getSizeClassInfo(SizeClassMap::BatchClassId));
519 Sci->FreeListInfo.PushedBlocks += Size;
520 BatchGroupT *BG = Sci->FreeListInfo.BlockList.front();
535 Sci->FreeListInfo.BlockList.push_front(BG);
600 void pushBlocksImpl(CacheT *C, uptr ClassId, SizeClassInfo *Sci,
602 REQUIRES(Sci->Mutex) {
645 Sci->FreeListInfo.PushedBlocks += Size;
646 BatchGroupT *Cur = Sci->FreeListInfo.BlockList.front();
662 Sci->FreeListInfo.BlockList.push_front(Cur);
664 Sci->FreeListInfo.BlockList.insert(Prev, Cur);
695 Sci->FreeListInfo.BlockList.insert(Prev, Cur);
707 u16 popBlocksImpl(CacheT *C, uptr ClassId, SizeClassInfo *Sci,
709 REQUIRES(Sci->Mutex) {
710 if (Sci->FreeListInfo.BlockList.empty())
714 Sci->FreeListInfo.BlockList.front()->Batches;
718 BatchGroupT *BG = Sci->FreeListInfo.BlockList.front();
719 Sci->FreeListInfo.BlockList.pop_front();
726 Sci->FreeListInfo.PoppedBlocks += 1;
760 BatchGroupT *BG = Sci->FreeListInfo.BlockList.front();
761 Sci->FreeListInfo.BlockList.pop_front();
773 Sci->FreeListInfo.PoppedBlocks += PopCount;
777 NOINLINE bool populateFreeList(CacheT *C, uptr ClassId, SizeClassInfo *Sci)
778 REQUIRES(Sci->Mutex) {
785 if (Sci->CurrentRegion) {
786 Region = Sci->CurrentRegion;
787 DCHECK_GT(Sci->CurrentRegionAllocated, 0U);
788 Offset = Sci->CurrentRegionAllocated;
790 DCHECK_EQ(Sci->CurrentRegionAllocated, 0U);
791 Region = allocateRegion(Sci, ClassId);
795 Sci->CurrentRegion = Region;
829 shuffle(ShuffleArray + I - N, N, &Sci->RandState);
830 pushBlocksImpl(C, ClassId, Sci, ShuffleArray + I - N, N,
839 shuffle(ShuffleArray + NumberOfBlocks - N, N, &Sci->RandState);
840 pushBlocksImpl(C, ClassId, Sci, &ShuffleArray[NumberOfBlocks - N], N,
843 pushBatchClassBlocks(Sci, ShuffleArray, NumberOfBlocks);
850 Sci->FreeListInfo.PushedBlocks -= NumberOfBlocks;
854 DCHECK_LE(Sci->CurrentRegionAllocated + AllocatedUser, RegionSize);
858 if (RegionSize - (Sci->CurrentRegionAllocated + AllocatedUser) < Size) {
859 Sci->CurrentRegion = 0;
860 Sci->CurrentRegionAllocated = 0;
862 Sci->CurrentRegionAllocated += AllocatedUser;
864 Sci->AllocatedUser += AllocatedUser;
869 void getStats(ScopedString *Str, uptr ClassId, SizeClassInfo *Sci)
870 REQUIRES(Sci->Mutex) {
871 if (Sci->AllocatedUser == 0)
875 Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks;
876 const uptr BytesInFreeList = Sci->AllocatedUser - InUse * BlockSize;
878 if (BytesInFreeList >= Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint) {
880 BytesInFreeList - Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint;
882 const uptr AvailableChunks = Sci->AllocatedUser / BlockSize;
887 ClassId, getSizeByClassId(ClassId), Sci->AllocatedUser >> 10,
888 Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks, InUse,
889 AvailableChunks, Sci->ReleaseInfo.NumReleasesAttempted,
890 Sci->ReleaseInfo.LastReleasedBytes >> 10, PushedBytesDelta >> 10);
893 void getSizeClassFragmentationInfo(SizeClassInfo *Sci, uptr ClassId,
894 ScopedString *Str) REQUIRES(Sci->Mutex) {
896 const uptr First = Sci->MinRegionIndex;
897 const uptr Last = Sci->MaxRegionIndex;
906 if (!Sci->FreeListInfo.BlockList.empty()) {
908 markFreeBlocks(Sci, ClassId, BlockSize, Base, NumberOfRegions,
914 const uptr TotalBlocks = Sci->AllocatedUser / BlockSize;
916 Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks;
943 NOINLINE uptr releaseToOSMaybe(SizeClassInfo *Sci, uptr ClassId,
945 REQUIRES(Sci->Mutex) {
948 DCHECK_GE(Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks);
950 Sci->AllocatedUser -
951 (Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks) *
962 !hasChanceToReleasePages(Sci, BlockSize, BytesInFreeList,
967 const uptr First = Sci->MinRegionIndex;
968 const uptr Last = Sci->MaxRegionIndex;
977 ++Sci->ReleaseInfo.NumReleasesAttempted;
983 PageReleaseContext Context = markFreeBlocks(Sci, ClassId, BlockSize, Base,
999 Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint = BytesInFreeList;
1000 Sci->ReleaseInfo.LastReleasedBytes = Recorder.getReleasedBytes();
1001 TotalReleasedBytes += Sci->ReleaseInfo.LastReleasedBytes;
1003 Sci->ReleaseInfo.LastReleaseAtNs = getMonotonicTimeFast();
1008 bool hasChanceToReleasePages(SizeClassInfo *Sci, uptr BlockSize,
1010 REQUIRES(Sci->Mutex) {
1011 DCHECK_GE(Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks);
1014 if (BytesInFreeList <= Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint)
1015 Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint = BytesInFreeList;
1034 BytesInFreeList - Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint;
1042 if (PushedBytesDelta < Sci->AllocatedUser / 16U)
1057 if (Sci->ReleaseInfo.LastReleaseAtNs +
1069 PageReleaseContext markFreeBlocks(SizeClassInfo *Sci, const uptr ClassId,
1073 REQUIRES(Sci->Mutex) {
1077 compactPtrGroupBase(compactPtr(ClassId, Sci->CurrentRegion));
1085 for (BatchGroupT &BG : Sci->FreeListInfo.BlockList) {
1091 ? Sci->CurrentRegionAllocated