Search in sources :

Example 51 with Log

use of com.oracle.svm.core.log.Log in project graal by oracle.

the class GarbageCollectorManagementFactory method visitWatchersReport.

private void visitWatchersReport() {
    final Log trace = Log.noopLog().string("[GCImpl.visitWatchersReport:").newline();
    /*
         * Run single-threaded (but not at a safepoint) so as not be bothered by concurrent
         * scrubbing of the list due to random garbage collections. There is still window if someone
         * has unregistered a watcher and then there is another collection, because that will scrub
         * the list I am walking, even though I am in a VMOperation. I consider that a small-enough
         * possibility.
         */
    VMOperation.enqueueBlockingNoSafepoint("GCImpl.visitWatchersReport", () -> {
        for (CollectionWatcher watcher = collectionWatcherList.getFirst(); watcher != null; watcher = watcher.getNextElement()) {
            try {
                watcher.report();
            } catch (Throwable t) {
                trace.string("[GCImpl.visitWatchersReport: Caught: ").string(t.getClass().getName()).string("]").newline();
            }
        }
    });
    trace.string("]").newline();
}
Also used : CollectionWatcher(com.oracle.svm.core.heap.CollectionWatcher) Log(com.oracle.svm.core.log.Log)

Example 52 with Log

use of com.oracle.svm.core.log.Log in project graal by oracle.

the class GarbageCollectorManagementFactory method printGCBefore.

/*
     * Implementation methods.
     */
private void printGCBefore(String cause) {
    final Log verboseGCLog = Log.log();
    final HeapImpl heap = HeapImpl.getHeapImpl();
    sizeBefore = ((SubstrateOptions.PrintGC.getValue() || HeapOptions.PrintHeapShape.getValue()) ? heap.getUsedChunkBytes() : WordFactory.zero());
    if (SubstrateOptions.VerboseGC.getValue() && getCollectionEpoch().equal(1)) {
        /* Print the command line options that shape the heap. */
        verboseGCLog.string("[Heap policy parameters: ").newline();
        verboseGCLog.string("  YoungGenerationSize: ").unsigned(HeapPolicy.getMaximumYoungGenerationSize()).newline();
        verboseGCLog.string("      MaximumHeapSize: ").unsigned(HeapPolicy.getMaximumHeapSize()).newline();
        verboseGCLog.string("      MinimumHeapSize: ").unsigned(HeapPolicy.getMinimumHeapSize()).newline();
        verboseGCLog.string("     AlignedChunkSize: ").unsigned(HeapPolicy.getAlignedHeapChunkSize()).newline();
        verboseGCLog.string("  LargeArrayThreshold: ").unsigned(HeapPolicy.getLargeArrayThreshold()).string("]").newline();
        if (HeapOptions.PrintHeapShape.getValue()) {
            HeapImpl.getHeapImpl().bootImageHeapBoundariesToLog(verboseGCLog);
        }
    }
    if (SubstrateOptions.VerboseGC.getValue()) {
        verboseGCLog.string("[");
        verboseGCLog.string("[");
        final long startTime = System.nanoTime();
        if (SubstrateOptions.PrintGCTimeStamps.getValue()) {
            verboseGCLog.unsigned(TimeUtils.roundNanosToMillis(Timer.getTimeSinceFirstAllocation(startTime))).string(" msec: ");
        } else {
            verboseGCLog.unsigned(startTime);
        }
        verboseGCLog.string(" GC:").string(" before").string("  epoch: ").unsigned(getCollectionEpoch()).string("  cause: ").string(cause);
        if (HeapOptions.PrintHeapShape.getValue()) {
            heap.report(verboseGCLog);
        }
        verboseGCLog.string("]").newline();
    }
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 53 with Log

use of com.oracle.svm.core.log.Log in project graal by oracle.

the class GarbageCollectorManagementFactory method swapSpaces.

private static void swapSpaces() {
    final Log trace = Log.noopLog().string("[GCImpl.swapSpaces:");
    final HeapImpl heap = HeapImpl.getHeapImpl();
    final OldGeneration oldGen = heap.getOldGeneration();
    oldGen.swapSpaces();
    trace.string("]").newline();
}
Also used : Log(com.oracle.svm.core.log.Log)

Example 54 with Log

use of com.oracle.svm.core.log.Log in project graal by oracle.

the class GarbageCollectorManagementFactory method visitWatchersAfter.

@SuppressWarnings("try")
private void visitWatchersAfter() {
    final Log trace = Log.noopLog().string("[GCImpl.visitWatchersAfter:").newline();
    trace.string("  Watchers after: ");
    try (Timer wat = watchersAfterTimer.open()) {
        /* Run the registered collection watchers. */
        for (CollectionWatcher watcher = collectionWatcherList.getFirst(); watcher != null; watcher = watcher.getNextElement()) {
            try {
                watcher.afterCollection();
            } catch (Throwable t) {
                trace.string("[GCImpl.visitWatchersAfter: Caught: ").string(t.getClass().getName()).string("]").newline();
            }
        }
    }
    trace.string("]").newline();
}
Also used : CollectionWatcher(com.oracle.svm.core.heap.CollectionWatcher) Log(com.oracle.svm.core.log.Log)

Example 55 with Log

use of com.oracle.svm.core.log.Log in project graal by oracle.

the class GarbageCollectorManagementFactory method printGCSummary.

@Override
public void printGCSummary() {
    final Log log = Log.log();
    final String prefix = "PrintGCSummary: ";
    /* Print GC configuration. */
    log.string(prefix).string("YoungGenerationSize: ").unsigned(HeapPolicy.getMaximumYoungGenerationSize()).newline();
    log.string(prefix).string("MinimumHeapSize: ").unsigned(HeapPolicy.getMinimumHeapSize()).newline();
    log.string(prefix).string("MaximumHeapSize: ").unsigned(HeapPolicy.getMaximumHeapSize()).newline();
    log.string(prefix).string("AlignedChunkSize: ").unsigned(HeapPolicy.getAlignedHeapChunkSize()).newline();
    /* Add in any young and pinned objects allocated since the last collection. */
    VMOperation.enqueueBlockingSafepoint("PrintGCSummaryShutdownHook", ThreadLocalAllocation::disableThreadLocalAllocation);
    final HeapImpl heap = HeapImpl.getHeapImpl();
    final Space youngSpace = heap.getYoungGeneration().getSpace();
    final UnsignedWord youngChunkBytes = youngSpace.getChunkBytes();
    final UnsignedWord youngObjectBytes = youngSpace.getObjectBytes();
    final Space pinnedSpace = heap.getOldGeneration().getPinnedFromSpace();
    final UnsignedWord pinnedChunkBytes = pinnedSpace.getChunkBytes().subtract(accounting.getPinnedChunkBytesAfter());
    final UnsignedWord pinnedObjectBytes = pinnedSpace.getObjectBytes().subtract(accounting.getPinnedObjectBytesAfter());
    /* Compute updated values. */
    final UnsignedWord allocatedNormalChunkBytes = accounting.getNormalChunkBytes().add(youngChunkBytes);
    final UnsignedWord allocatedNormalObjectBytes = accounting.getNormalObjectBytes().add(youngObjectBytes);
    final UnsignedWord allocatedPinnedChunkBytes = accounting.getPinnedChunkBytes().add(pinnedChunkBytes);
    final UnsignedWord allocatedPinnedObjectBytes = accounting.getPinnedObjectBytes().add(pinnedObjectBytes);
    final UnsignedWord allocatedTotalChunkBytes = allocatedNormalChunkBytes.add(allocatedPinnedChunkBytes);
    final UnsignedWord allocatedTotalObjectBytes = allocatedNormalObjectBytes.add(allocatedPinnedObjectBytes);
    /* Print the total bytes allocated and collected by chunks. */
    log.string(prefix).string("CollectedTotalChunkBytes: ").signed(accounting.getCollectedTotalChunkBytes()).newline();
    log.string(prefix).string("CollectedTotalObjectBytes: ").signed(accounting.getCollectedTotalObjectBytes()).newline();
    log.string(prefix).string("AllocatedNormalChunkBytes: ").signed(allocatedNormalChunkBytes).newline();
    log.string(prefix).string("AllocatedNormalObjectBytes: ").signed(allocatedNormalObjectBytes).newline();
    log.string(prefix).string("AllocatedPinnedChunkBytes: ").signed(allocatedPinnedChunkBytes).newline();
    log.string(prefix).string("AllocatedPinnedObjectBytes: ").signed(allocatedPinnedObjectBytes).newline();
    log.string(prefix).string("AllocatedTotalChunkBytes: ").signed(allocatedTotalChunkBytes).newline();
    log.string(prefix).string("AllocatedTotalObjectBytes: ").signed(allocatedTotalObjectBytes).newline();
    /* Print the collection counts and times. */
    final long incrementalNanos = accounting.getIncrementalCollectionTotalNanos();
    log.string(prefix).string("IncrementalGCCount: ").signed(accounting.getIncrementalCollectionCount()).newline();
    log.string(prefix).string("IncrementalGCNanos: ").signed(incrementalNanos).newline();
    final long completeNanos = accounting.getCompleteCollectionTotalNanos();
    log.string(prefix).string("CompleteGCCount: ").signed(accounting.getCompleteCollectionCount()).newline();
    log.string(prefix).string("CompleteGCNanos: ").signed(completeNanos).newline();
    /* Compute a GC load percent. */
    final long gcNanos = incrementalNanos + completeNanos;
    final long mutatorNanos = mutatorTimer.getCollectedNanos();
    final long totalNanos = gcNanos + mutatorNanos;
    final long roundedGCLoad = (0 < totalNanos ? TimeUtils.roundedDivide(100 * gcNanos, totalNanos) : 0);
    log.string(prefix).string("GCNanos: ").signed(gcNanos).newline();
    log.string(prefix).string("TotalNanos: ").signed(totalNanos).newline();
    log.string(prefix).string("GCLoadPercent: ").signed(roundedGCLoad).newline();
}
Also used : Log(com.oracle.svm.core.log.Log) UnsignedWord(org.graalvm.word.UnsignedWord)

Aggregations

Log (com.oracle.svm.core.log.Log)130 Pointer (org.graalvm.word.Pointer)30 UnsignedWord (org.graalvm.word.UnsignedWord)30 IsolateThread (org.graalvm.nativeimage.IsolateThread)4 CodePointer (org.graalvm.nativeimage.c.function.CodePointer)4 Uninterruptible (com.oracle.svm.core.annotate.Uninterruptible)3 CollectionWatcher (com.oracle.svm.core.heap.CollectionWatcher)3 DiscoverableReference (com.oracle.svm.core.heap.DiscoverableReference)3 XOptions (com.oracle.svm.core.option.XOptions)3 AlwaysInline (com.oracle.svm.core.annotate.AlwaysInline)2 CEntryPointOptions (com.oracle.svm.core.c.function.CEntryPointOptions)2 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)2 CEntryPoint (org.graalvm.nativeimage.c.function.CEntryPoint)2 RestrictHeapAccess (com.oracle.svm.core.annotate.RestrictHeapAccess)1 CodeInfoQueryResult (com.oracle.svm.core.code.CodeInfoQueryResult)1 SubstrateInstalledCode (com.oracle.svm.core.deopt.SubstrateInstalledCode)1 AlignedHeader (com.oracle.svm.core.genscavenge.AlignedHeapChunk.AlignedHeader)1 UnalignedHeader (com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader)1 AllocationFreeList (com.oracle.svm.core.heap.AllocationFreeList)1 NoAllocationVerifier (com.oracle.svm.core.heap.NoAllocationVerifier)1