use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionListPointer in project openj9 by eclipse.
the class DumpSegregatedStatsCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (!GCExtensions.isSegregatedHeap()) {
out.append("Only valid for a segregated heap\n");
return;
}
try {
/* Get the region pool */
MM_GCExtensionsPointer extensions = GCExtensions.getGCExtensionsPointer();
MM_RealtimeGCPointer realtimeGC = MM_RealtimeGCPointer.cast(extensions._globalCollector());
MM_RegionPoolSegregatedPointer regionPool = realtimeGC._memoryPool()._regionPool();
/* Get the size classes */
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9VMGCSizeClassesPointer sizeClasses = vm.realtimeSizeClasses();
long countTotal = 0;
long countAvailableSmallTotal = 0;
long countFullSmallTotal = 0;
long darkMatterBytesTotal = 0;
long allocCacheBytesTotal = 0;
/* arrayOffset is the total offset into a two dimensional array. Used to walk the
* the array linearly */
long arrayOffset = J9Consts.J9VMGC_SIZECLASSES_MIN_SMALL * MM_RegionPoolSegregated.NUM_DEFRAG_BUCKETS;
out.append("sizeClass | full | available | total | free cell count | dark | cache\n");
out.append("===============================================================================\n");
for (long sizeClassIndex = J9Consts.J9VMGC_SIZECLASSES_MIN_SMALL; sizeClassIndex <= J9Consts.J9VMGC_SIZECLASSES_MAX_SMALL; sizeClassIndex++) {
/* Print the sizeclass */
UDATA cellSize = sizeClasses.smallCellSizesEA().at(sizeClassIndex);
out.format("%2d: %5d | ", sizeClassIndex, cellSize.longValue());
MM_HeapRegionListPointer heapRegionQueue = MM_HeapRegionListPointer.cast(regionPool._smallFullRegionsEA().at(sizeClassIndex));
long countSmall = getTotalRegions(heapRegionQueue);
countFullSmallTotal += countSmall;
/* Print the number of full regions of this size class */
out.format("%4d | ", countSmall);
/* The number of free cells of this sizeclass */
long freeCellCount = 0;
for (long i = 0; i < MM_RegionPoolSegregated.NUM_DEFRAG_BUCKETS; i++) {
long count = 0;
MM_LockingHeapRegionQueuePointer heapRegionList = MM_LockingHeapRegionQueuePointer.cast(regionPool._smallAvailableRegionsEA().add(arrayOffset).at(0));
for (long j = 0; j < regionPool._splitAvailableListSplitCount().longValue(); j++) {
count += getTotalRegions(heapRegionList);
freeCellCount += getFreeCellCount(heapRegionList);
heapRegionList = heapRegionList.add(1);
}
/* increment to the next list */
arrayOffset += 1;
countSmall += count;
countAvailableSmallTotal += count;
/* Print the number of available regions in this defrag bucket */
out.format("%4d ", count);
}
countTotal += countSmall;
/* Print the total number of regions of this size class, and the number of free cells */
out.format("| %5d | %15d |", countSmall, freeCellCount);
/* Print the percentage of darkmatter in this region */
long darkMatterCellCount = regionPool._darkMatterCellCountEA().at(sizeClassIndex).longValue();
darkMatterBytesTotal += darkMatterCellCount * cellSize.longValue();
out.format("%%%3d | ", countSmall == 0 ? 0 : darkMatterCellCount / (countSmall * cellSize.longValue()));
/* Calculate the number of bytes in allocation caches */
long allocCacheSize = 0;
J9VMThreadPointer mainThread = vm.mainThread();
if (mainThread.notNull()) {
J9VMThreadPointer threadCursor = vm.mainThread();
do {
J9VMGCSegregatedAllocationCacheEntryPointer cache = threadCursor.segregatedAllocationCache();
cache = cache.add(sizeClassIndex);
allocCacheSize += cache.top().longValue() - cache.current().longValue();
threadCursor = threadCursor.linkNext();
} while (!threadCursor.eq(mainThread));
}
out.format("%5d\n", allocCacheSize);
allocCacheBytesTotal += allocCacheSize;
}
long regionSize = extensions.heap()._heapRegionManager()._regionSize().longValue();
out.format("region size %d\n", regionSize);
long arrayletLeafSize = extensions._omrVM()._arrayletLeafSize().longValue();
out.format("arraylet leaf size %d\n", arrayletLeafSize);
out.format("small total (full, available) region count %d (%d, %d)\n", countTotal, countFullSmallTotal, countAvailableSmallTotal);
long countFullArraylet = getTotalRegions(regionPool._arrayletFullRegions());
long countAvailArraylet = getTotalRegions(regionPool._arrayletAvailableRegions());
long countTotalArraylet = countFullArraylet + countAvailArraylet;
countTotal += countTotalArraylet;
out.format("arraylet total (full, available) region count %d (%d %d)\n", countTotalArraylet, countFullArraylet, countAvailArraylet);
long countLarge = getTotalRegions(regionPool._largeFullRegions());
countTotal += countLarge;
out.format("large full region count %d\n", countLarge);
long countFree = getTotalRegions(regionPool._singleFreeList());
countTotal += countFree;
out.format("free region count %d\n", countFree);
long countMultiFree = getTotalRegions(regionPool._multiFreeList());
countTotal += countMultiFree;
out.format("multiFree region count %d\n", countMultiFree);
long countCoalesce = getTotalRegions(regionPool._coalesceFreeList());
countTotal += countCoalesce;
out.format("coalesce region count %d\n", countCoalesce);
long heapSize = countTotal * regionSize;
out.format("total region count %d, total heap size %d \n", countTotal, heapSize);
out.format("dark matter total bytes %d (%2.2f%% of heap)\n", darkMatterBytesTotal, 100.0 * darkMatterBytesTotal / heapSize);
out.format("allocation cache total bytes %d (%2.2f%% of heap)\n", allocCacheBytesTotal, 100.0 * allocCacheBytesTotal / heapSize);
} catch (CorruptDataException e) {
e.printStackTrace();
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionListPointer in project openj9 by eclipse.
the class DumpSegregatedStatsCommand method getTotalRegions.
/**
* Based off of MM_HeapRegionQueue::getTotalRegions. Returns the number of regions.
* This function will calculate the number of regions differently according to the type of
* the actual subclass.
* @throws CorruptDataException
*/
public long getTotalRegions(MM_HeapRegionListPointer heapRegionList) throws CorruptDataException {
long count = 0;
StructurePointer heapRegionQueue = heapRegionList.getAsRuntimeType();
if (heapRegionQueue instanceof MM_LockingHeapRegionQueuePointer) {
MM_LockingHeapRegionQueuePointer lockingHeapRegionQueue = (MM_LockingHeapRegionQueuePointer) heapRegionQueue;
if (lockingHeapRegionQueue._singleRegionsOnly()) {
count = lockingHeapRegionQueue._length().longValue();
} else {
MM_HeapRegionDescriptorSegregatedPointer heapRegionDescriptorSegregated = lockingHeapRegionQueue._head();
while (heapRegionDescriptorSegregated.notNull()) {
count += heapRegionDescriptorSegregated._regionsInSpan().longValue();
heapRegionDescriptorSegregated = heapRegionDescriptorSegregated._next();
}
}
} else if (heapRegionQueue instanceof MM_LockingFreeHeapRegionListPointer) {
MM_LockingFreeHeapRegionListPointer lockingFreeHeapRegionQueue = (MM_LockingFreeHeapRegionListPointer) heapRegionQueue;
MM_HeapRegionDescriptorSegregatedPointer heapRegionDescriptorSegregated = lockingFreeHeapRegionQueue._head();
while (heapRegionDescriptorSegregated.notNull()) {
count += heapRegionDescriptorSegregated._regionsInSpan().longValue();
heapRegionDescriptorSegregated = heapRegionDescriptorSegregated._next();
}
} else {
throw new CorruptDataException("Bad HeapRegionList type");
}
return count;
}
use of com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionListPointer in project openj9 by eclipse.
the class DumpSegregatedStatsCommand method getFreeCellCount.
/**
* Count the number of free cells in the entire MM_HeapRegionList
* @throws CorruptDataException
*/
public long getFreeCellCount(MM_HeapRegionListPointer heapRegionList) throws CorruptDataException {
StructurePointer heapRegionQueue = heapRegionList.getAsRuntimeType();
long freeCellCount = 0;
if (heapRegionQueue instanceof MM_LockingHeapRegionQueuePointer) {
MM_LockingHeapRegionQueuePointer lockingHeapRegionQueue = (MM_LockingHeapRegionQueuePointer) heapRegionQueue;
MM_HeapRegionDescriptorSegregatedPointer heapRegionDescriptorSegregated = lockingHeapRegionQueue._head();
while (heapRegionDescriptorSegregated.notNull()) {
freeCellCount += getFreeCellCount(heapRegionDescriptorSegregated);
heapRegionDescriptorSegregated = heapRegionDescriptorSegregated._next();
}
} else if (heapRegionQueue instanceof MM_LockingFreeHeapRegionListPointer) {
MM_LockingFreeHeapRegionListPointer lockingFreeHeapRegionQueue = (MM_LockingFreeHeapRegionListPointer) heapRegionQueue;
MM_HeapRegionDescriptorSegregatedPointer heapRegionDescriptorSegregated = lockingFreeHeapRegionQueue._head();
while (heapRegionDescriptorSegregated.notNull()) {
freeCellCount += getFreeCellCount(heapRegionDescriptorSegregated);
heapRegionDescriptorSegregated = heapRegionDescriptorSegregated._next();
}
} else {
throw new CorruptDataException("Bad HeapRegionList type");
}
return freeCellCount;
}
Aggregations