Lines Matching defs:Sci
85 SizeClassInfo *Sci = getSizeClassInfo(I);
86 Sci->RandState = getRandomU32(&Seed);
87 // Sci->MaxRegionIndex is already initialized to 0.
88 Sci->MinRegionIndex = NumRegions;
89 Sci->ReleaseInfo.LastReleaseAtNs = Time;
109 SizeClassInfo *Sci = getSizeClassInfo(I);
110 ScopedLock L(Sci->Mutex);
111 if (Sci->MinRegionIndex < MinRegionIndex)
112 MinRegionIndex = Sci->MinRegionIndex;
113 if (Sci->MaxRegionIndex > MaxRegionIndex)
114 MaxRegionIndex = Sci->MaxRegionIndex;
115 *Sci = {};
133 SizeClassInfo *Sci = getSizeClassInfo(I);
134 ScopedLock L1(Sci->Mutex);
136 for (BatchGroupT &BG : Sci->FreeListInfo.BlockList) {
144 DCHECK_EQ(TotalBlocks, Sci->AllocatedUser / BlockSize);
145 DCHECK_EQ(Sci->FreeListInfo.PushedBlocks, Sci->FreeListInfo.PoppedBlocks);
148 SizeClassInfo *Sci = getSizeClassInfo(SizeClassMap::BatchClassId);
149 ScopedLock L1(Sci->Mutex);
151 for (BatchGroupT &BG : Sci->FreeListInfo.BlockList) {
164 Sci->AllocatedUser / BlockSize);
166 Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks;
200 SizeClassInfo *Sci = getSizeClassInfo(ClassId);
201 ScopedLock L(Sci->Mutex);
203 u16 PopCount = popBlocksImpl(C, ClassId, Sci, ToArray, MaxBlockCount);
205 if (UNLIKELY(!populateFreeList(C, ClassId, Sci)))
207 PopCount = popBlocksImpl(C, ClassId, Sci, ToArray, MaxBlockCount);
219 SizeClassInfo *Sci = getSizeClassInfo(ClassId);
221 ScopedLock L(Sci->Mutex);
222 pushBatchClassBlocks(Sci, Array, Size);
245 ScopedLock L(Sci->Mutex);
246 pushBlocksImpl(C, ClassId, Sci, Array, Size, SameGroup);
275 SizeClassInfo *Sci = getSizeClassInfo(I);
279 Sci->Mutex.assertHeld();
280 if (Sci->MinRegionIndex < MinRegionIndex)
281 MinRegionIndex = Sci->MinRegionIndex;
282 if (Sci->MaxRegionIndex > MaxRegionIndex)
283 MaxRegionIndex = Sci->MaxRegionIndex;
307 SizeClassInfo *Sci = getSizeClassInfo(I);
308 ScopedLock L(Sci->Mutex);
309 TotalMapped += Sci->AllocatedUser;
310 PoppedBlocks += Sci->FreeListInfo.PoppedBlocks;
311 PushedBlocks += Sci->FreeListInfo.PushedBlocks;
317 SizeClassInfo *Sci = getSizeClassInfo(I);
318 ScopedLock L(Sci->Mutex);
319 getStats(Str, I, Sci);
329 SizeClassInfo *Sci = getSizeClassInfo(I);
330 ScopedLock L(Sci->Mutex);
331 getSizeClassFragmentationInfo(Sci, I, Str);
348 SizeClassInfo *Sci = getSizeClassInfo(ClassId);
351 ScopedLock L(Sci->Mutex);
352 return releaseToOSMaybe(Sci, ClassId, ReleaseType);
360 SizeClassInfo *Sci = getSizeClassInfo(I);
361 ScopedLock L(Sci->Mutex);
362 TotalReleasedBytes += releaseToOSMaybe(Sci, I, ReleaseType);
449 uptr allocateRegion(SizeClassInfo *Sci, uptr ClassId) REQUIRES(Sci->Mutex) {
460 // Sci->Mutex is held by the caller, updating the Min/Max is safe.
462 if (RegionIndex < Sci->MinRegionIndex)
463 Sci->MinRegionIndex = RegionIndex;
464 if (RegionIndex > Sci->MaxRegionIndex)
465 Sci->MaxRegionIndex = RegionIndex;
477 void pushBatchClassBlocks(SizeClassInfo *Sci, CompactPtrT *Array, u32 Size)
478 REQUIRES(Sci->Mutex) {
479 DCHECK_EQ(Sci, getSizeClassInfo(SizeClassMap::BatchClassId));
516 Sci->FreeListInfo.PushedBlocks += Size;
517 BatchGroupT *BG = Sci->FreeListInfo.BlockList.front();
535 Sci->FreeListInfo.BlockList.push_front(BG);
605 void pushBlocksImpl(CacheT *C, uptr ClassId, SizeClassInfo *Sci,
607 REQUIRES(Sci->Mutex) {
653 Sci->FreeListInfo.PushedBlocks += Size;
654 BatchGroupT *Cur = Sci->FreeListInfo.BlockList.front();
670 Sci->FreeListInfo.BlockList.push_front(Cur);
672 Sci->FreeListInfo.BlockList.insert(Prev, Cur);
703 Sci->FreeListInfo.BlockList.insert(Prev, Cur);
715 u16 popBlocksImpl(CacheT *C, uptr ClassId, SizeClassInfo *Sci,
717 REQUIRES(Sci->Mutex) {
718 if (Sci->FreeListInfo.BlockList.empty())
722 Sci->FreeListInfo.BlockList.front()->Batches;
726 BatchGroupT *BG = Sci->FreeListInfo.BlockList.front();
727 Sci->FreeListInfo.BlockList.pop_front();
734 Sci->FreeListInfo.PoppedBlocks += 1;
768 BatchGroupT *BG = Sci->FreeListInfo.BlockList.front();
769 Sci->FreeListInfo.BlockList.pop_front();
781 Sci->FreeListInfo.PoppedBlocks += PopCount;
785 NOINLINE bool populateFreeList(CacheT *C, uptr ClassId, SizeClassInfo *Sci)
786 REQUIRES(Sci->Mutex) {
793 if (Sci->CurrentRegion) {
794 Region = Sci->CurrentRegion;
795 DCHECK_GT(Sci->CurrentRegionAllocated, 0U);
796 Offset = Sci->CurrentRegionAllocated;
798 DCHECK_EQ(Sci->CurrentRegionAllocated, 0U);
799 Region = allocateRegion(Sci, ClassId);
803 Sci->CurrentRegion = Region;
837 shuffle(ShuffleArray + I - N, N, &Sci->RandState);
838 pushBlocksImpl(C, ClassId, Sci, ShuffleArray + I - N, N,
847 shuffle(ShuffleArray + NumberOfBlocks - N, N, &Sci->RandState);
848 pushBlocksImpl(C, ClassId, Sci, &ShuffleArray[NumberOfBlocks - N], N,
851 pushBatchClassBlocks(Sci, ShuffleArray, NumberOfBlocks);
858 Sci->FreeListInfo.PushedBlocks -= NumberOfBlocks;
862 DCHECK_LE(Sci->CurrentRegionAllocated + AllocatedUser, RegionSize);
866 if (RegionSize - (Sci->CurrentRegionAllocated + AllocatedUser) < Size) {
867 Sci->CurrentRegion = 0;
868 Sci->CurrentRegionAllocated = 0;
870 Sci->CurrentRegionAllocated += AllocatedUser;
872 Sci->AllocatedUser += AllocatedUser;
877 void getStats(ScopedString *Str, uptr ClassId, SizeClassInfo *Sci)
878 REQUIRES(Sci->Mutex) {
879 if (Sci->AllocatedUser == 0)
883 Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks;
884 const uptr BytesInFreeList = Sci->AllocatedUser - InUse * BlockSize;
886 if (BytesInFreeList >= Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint) {
888 BytesInFreeList - Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint;
890 const uptr AvailableChunks = Sci->AllocatedUser / BlockSize;
894 ClassId, getSizeByClassId(ClassId), Sci->AllocatedUser >> 10,
895 Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks,
896 InUse, AvailableChunks, Sci->ReleaseInfo.RangesReleased,
897 Sci->ReleaseInfo.LastReleasedBytes >> 10,
901 void getSizeClassFragmentationInfo(SizeClassInfo *Sci, uptr ClassId,
902 ScopedString *Str) REQUIRES(Sci->Mutex) {
904 const uptr First = Sci->MinRegionIndex;
905 const uptr Last = Sci->MaxRegionIndex;
914 if (!Sci->FreeListInfo.BlockList.empty()) {
916 markFreeBlocks(Sci, ClassId, BlockSize, Base, NumberOfRegions,
922 const uptr TotalBlocks = Sci->AllocatedUser / BlockSize;
924 Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks;
951 NOINLINE uptr releaseToOSMaybe(SizeClassInfo *Sci, uptr ClassId,
953 REQUIRES(Sci->Mutex) {
956 DCHECK_GE(Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks);
958 Sci->AllocatedUser -
959 (Sci->FreeListInfo.PoppedBlocks - Sci->FreeListInfo.PushedBlocks) *
970 !hasChanceToReleasePages(Sci, BlockSize, BytesInFreeList,
975 const uptr First = Sci->MinRegionIndex;
976 const uptr Last = Sci->MaxRegionIndex;
987 PageReleaseContext Context = markFreeBlocks(Sci, ClassId, BlockSize, Base,
1003 Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint = BytesInFreeList;
1004 Sci->ReleaseInfo.RangesReleased += Recorder.getReleasedRangesCount();
1005 Sci->ReleaseInfo.LastReleasedBytes = Recorder.getReleasedBytes();
1006 TotalReleasedBytes += Sci->ReleaseInfo.LastReleasedBytes;
1008 Sci->ReleaseInfo.LastReleaseAtNs = getMonotonicTimeFast();
1013 bool hasChanceToReleasePages(SizeClassInfo *Sci, uptr BlockSize,
1015 REQUIRES(Sci->Mutex) {
1016 DCHECK_GE(Sci->FreeListInfo.PoppedBlocks, Sci->FreeListInfo.PushedBlocks);
1019 if (BytesInFreeList <= Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint)
1020 Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint = BytesInFreeList;
1039 BytesInFreeList - Sci->ReleaseInfo.BytesInFreeListAtLastCheckpoint;
1047 if (PushedBytesDelta < Sci->AllocatedUser / 16U)
1062 if (Sci->ReleaseInfo.LastReleaseAtNs +
1074 PageReleaseContext markFreeBlocks(SizeClassInfo *Sci, const uptr ClassId,
1078 REQUIRES(Sci->Mutex) {
1082 compactPtrGroupBase(compactPtr(ClassId, Sci->CurrentRegion));
1090 for (BatchGroupT &BG : Sci->FreeListInfo.BlockList) {
1096 ? Sci->CurrentRegionAllocated