Search in sources :

Example 1 with GraalTruffleRuntime

use of org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime in project graal by oracle.

the class StatisticsListener method printStatistics.

private void printStatistics() {
    GraalTruffleRuntime rt = runtime;
    long endTime = System.nanoTime();
    rt.log("Truffle runtime statistics:");
    printStatistic(rt, "Compilations", compilations);
    printStatistic(rt, "  Success", success);
    printStatistic(rt, "  Failed", failures);
    printStatistic(rt, "  Interrupted", compilations - (success + failures));
    printStatistic(rt, "Invalidated", invalidations);
    printStatistic(rt, "Queues", queues);
    printStatistic(rt, "Dequeues", dequeues);
    printStatistic(rt, "Splits", splits);
    printStatistic(rt, "Compilation Accuracy", 1.0 - invalidations / (double) compilations);
    printStatistic(rt, "Queue Accuracy", 1.0 - dequeues / (double) queues);
    printStatistic(rt, "Compilation Utilization", compilationTime.getSum() / (double) (endTime - firstCompilation));
    printStatistic(rt, "Remaining Compilation Queue", rt.getCompilationQueueSize());
    printStatistic(rt, "Times defered until compilation", deferCompilations);
    printStatisticTime(rt, "Time to queue", timeToQueue);
    printStatisticTime(rt, "Time to compilation", timeToCompilation);
    printStatisticTime(rt, "Compilation time", compilationTime);
    printStatisticTime(rt, "  Truffle Tier", compilationTimeTruffleTier);
    printStatisticTime(rt, "  Graal Tier", compilationTimeGraalTier);
    printStatisticTime(rt, "  Code Installation", compilationTimeCodeInstallation);
    printStatistic(rt, "Truffle node count", nodeCount);
    printStatistic(rt, "  Trivial", nodeCountTrivial);
    printStatistic(rt, "  Non Trivial", nodeCountNonTrivial);
    printStatistic(rt, "    Monomorphic", nodeCountMonomorphic);
    printStatistic(rt, "    Polymorphic", nodeCountPolymorphic);
    printStatistic(rt, "    Megamorphic", nodeCountMegamorphic);
    printStatistic(rt, "Truffle call count", callCount);
    printStatistic(rt, "  Indirect", callCountIndirect);
    printStatistic(rt, "  Direct", callCountDirect);
    printStatistic(rt, "    Dispatched", callCountDirectDispatched);
    printStatistic(rt, "    Inlined", callCountDirectInlined);
    printStatistic(rt, "    ----------");
    printStatistic(rt, "    Cloned", callCountDirectCloned);
    printStatistic(rt, "    Not Cloned", callCountDirectNotCloned);
    printStatistic(rt, "Truffle loops", loopCount);
    printStatistic(rt, "Graal node count");
    printStatistic(rt, "  After Truffle Tier", truffleTierNodeCount);
    printStatistic(rt, "  After Graal Tier", graalTierNodeCount);
    printStatistic(rt, "Graal compilation result");
    printStatistic(rt, "  Code size", compilationResultCodeSize);
    printStatistic(rt, "  Total frame size", compilationResultTotalFrameSize);
    printStatistic(rt, "  Exception handlers", compilationResultExceptionHandlers);
    printStatistic(rt, "  Infopoints", compilationResultInfopoints);
    compilationResultInfopointStatistics.printStatistics(rt, Function.identity());
    printStatistic(rt, "  Marks", compilationResultMarks);
    printStatistic(rt, "  Data references", compilationResultDataPatches);
    if (TruffleCompilerOptions.getValue(TruffleCompilationStatisticDetails)) {
        printStatistic(rt, "Truffle nodes");
        nodeStatistics.printStatistics(rt, Class::getSimpleName);
        printStatistic(rt, "Graal nodes after Truffle tier");
        truffleTierNodeStatistics.printStatistics(rt, Function.identity());
        printStatistic(rt, "Graal nodes after Graal tier");
        graalTierNodeStatistics.printStatistics(rt, Function.identity());
    }
}
Also used : GraalTruffleRuntime(org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime)

Example 2 with GraalTruffleRuntime

use of org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime in project graal by oracle.

the class TransferToInterpreterTest method test.

@Test
public void test() {
    RootNode rootNode = new TestRootNode();
    GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
    OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(rootNode);
    target.call(0);
    Assert.assertFalse(target.isValid());
    OptionValues options = TruffleCompilerOptions.getOptions();
    DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
    final OptimizedCallTarget compilable = target;
    TruffleCompilerImpl compiler = (TruffleCompilerImpl) runtime.newTruffleCompiler();
    CompilationIdentifier compilationId = compiler.getCompilationIdentifier(compilable);
    TruffleInliningPlan inliningPlan = new TruffleInlining(compilable, new DefaultInliningPolicy());
    compiler.compileAST(debug, compilable, inliningPlan, compilationId, null, null);
    Assert.assertTrue(target.isValid());
    target.call(0);
    Assert.assertTrue(target.isValid());
    target.call(1);
    Assert.assertFalse(target.isValid());
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) TruffleInliningPlan(org.graalvm.compiler.truffle.common.TruffleInliningPlan) CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) TruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl) GraalTruffleRuntime(org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) DebugContext(org.graalvm.compiler.debug.DebugContext) Test(org.junit.Test)

Example 3 with GraalTruffleRuntime

use of org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime in project graal by oracle.

the class PerformanceWarningTest method testHelper.

@SuppressWarnings("try")
private static void testHelper(RootNode rootNode, boolean expectException, String... outputStrings) {
    GraalTruffleRuntime runtime = GraalTruffleRuntime.getRuntime();
    OptimizedCallTarget target = (OptimizedCallTarget) runtime.createCallTarget(rootNode);
    // Compile and capture output to TTY.
    ByteArrayOutputStream outContent = new ByteArrayOutputStream();
    boolean seenException = false;
    try (TTY.Filter filter = new TTY.Filter(new LogStream(outContent))) {
        try (TruffleOptionsOverrideScope scope = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TraceTrufflePerformanceWarnings, Boolean.TRUE);
            TruffleOptionsOverrideScope scope2 = TruffleCompilerOptions.overrideOptions(TruffleCompilerOptions.TrufflePerformanceWarningsAreFatal, Boolean.TRUE)) {
            OptionValues options = TruffleCompilerOptions.getOptions();
            DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
            try (DebugCloseable d = debug.disableIntercept();
                DebugContext.Scope s = debug.scope("PerformanceWarningTest")) {
                final OptimizedCallTarget compilable = target;
                TruffleCompilerImpl compiler = (TruffleCompilerImpl) runtime.newTruffleCompiler();
                CompilationIdentifier compilationId = compiler.getCompilationIdentifier(compilable);
                TruffleInliningPlan inliningPlan = new TruffleInlining(compilable, new DefaultInliningPolicy());
                compiler.compileAST(debug, compilable, inliningPlan, compilationId, null, null);
            }
        } catch (AssertionError e) {
            seenException = true;
            if (!expectException) {
                throw new AssertionError("Unexpected exception caught", e);
            }
        }
    }
    if (expectException && !seenException) {
        Assert.assertTrue("Expected exception not caught.", false);
    }
    // Check output on TTY.
    String output = outContent.toString();
    if (outputStrings == EMPTY_PERF_WARNINGS) {
        Assert.assertEquals("", output);
    } else {
        for (String s : outputStrings) {
            Assert.assertTrue(String.format("Root node class %s: \"%s\" not found in output \"%s\"", rootNode.getClass(), s, output), output.contains(s));
        }
    }
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) TruffleCompilerImpl(org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LogStream(org.graalvm.compiler.debug.LogStream) DebugContext(org.graalvm.compiler.debug.DebugContext) TruffleInliningPlan(org.graalvm.compiler.truffle.common.TruffleInliningPlan) GraalTruffleRuntime(org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime) DefaultInliningPolicy(org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy) TruffleInlining(org.graalvm.compiler.truffle.runtime.TruffleInlining) TTY(org.graalvm.compiler.debug.TTY) TruffleOptionsOverrideScope(org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable)

Example 4 with GraalTruffleRuntime

use of org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime in project graal by oracle.

the class SLWaitForOptimizationBuiltin method waitForOptimization.

@Specialization
public SLFunction waitForOptimization(SLFunction function, long timeout) {
    OptimizedCallTarget target = (OptimizedCallTarget) function.getCallTarget();
    GraalTruffleRuntime runtime = ((GraalTruffleRuntime) Truffle.getRuntime());
    try {
        runtime.waitForCompilation(target, timeout);
    } catch (ExecutionException | TimeoutException e) {
        throw new RuntimeException(e);
    }
    return function;
}
Also used : GraalTruffleRuntime(org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) Specialization(com.oracle.truffle.api.dsl.Specialization)

Aggregations

GraalTruffleRuntime (org.graalvm.compiler.truffle.runtime.GraalTruffleRuntime)4 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)3 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 OptionValues (org.graalvm.compiler.options.OptionValues)2 TruffleInliningPlan (org.graalvm.compiler.truffle.common.TruffleInliningPlan)2 TruffleCompilerImpl (org.graalvm.compiler.truffle.compiler.TruffleCompilerImpl)2 DefaultInliningPolicy (org.graalvm.compiler.truffle.runtime.DefaultInliningPolicy)2 TruffleInlining (org.graalvm.compiler.truffle.runtime.TruffleInlining)2 Specialization (com.oracle.truffle.api.dsl.Specialization)1 RootNode (com.oracle.truffle.api.nodes.RootNode)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 LogStream (org.graalvm.compiler.debug.LogStream)1 TTY (org.graalvm.compiler.debug.TTY)1 TruffleOptionsOverrideScope (org.graalvm.compiler.truffle.common.TruffleCompilerOptions.TruffleOptionsOverrideScope)1 Test (org.junit.Test)1