# HG changeset patch # User Christian Humer # Date 1412096446 -7200 # Node ID 43655130d0ab9ae27e59a442115916df7ce6f0d8 # Parent 9eb112c9337d5032c200602adc4fb742a54d46e6 Truffle: added a performance warning for number of nodes in a single Truffle cache entry. diff -r 9eb112c9337d -r 43655130d0ab graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Tue Sep 30 15:26:07 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetLog.java Tue Sep 30 19:00:46 2014 +0200 @@ -270,6 +270,10 @@ } + public static void logPerformanceWarning(String details, Map properties) { + log(0, "perf warn", details, properties); + } + static void log(int indent, String msg, String details, Map properties) { StringBuilder sb = new StringBuilder(); sb.append(String.format("[truffle] %-16s ", msg)); diff -r 9eb112c9337d -r 43655130d0ab graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Sep 30 15:26:07 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Tue Sep 30 19:00:46 2014 +0200 @@ -61,6 +61,7 @@ import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.api.nodes.Node.Child; import com.oracle.truffle.api.nodes.Node.Children; +import static com.oracle.graal.truffle.OptimizedCallTargetLog.*; /** * Class performing the partial evaluation starting from the root node of an AST. @@ -280,8 +281,7 @@ InliningDecision decision = inlining.findByCall(callNode); if (decision == null) { if (TruffleCompilerOptions.PrintTrufflePerformanceWarnings.getValue()) { - OptimizedCallTargetLog.log(0, "perf warn", String.format( - "%s '%s' is reached using partial evaluation but it is not reachable in the Truffle AST. Did you miss @%s or @%s annotation on a node field?. ", + logPerformanceWarning(String.format("%s '%s' is reached using partial evaluation but it is not reachable in the Truffle AST. Did you miss @%s or @%s annotation on a node field?. ", DirectCallNode.class.getSimpleName(), callNode, Child.class.getSimpleName(), Children.class.getSimpleName()), callNode.getRootNode().getDebugProperties()); } return null; @@ -296,7 +296,7 @@ OptimizedCallTarget currentTarget = decision.getProfile().getCallNode().getCurrentCallTarget(); if (decision.getTarget() != currentTarget) { if (TruffleCompilerOptions.PrintTrufflePerformanceWarnings.getValue()) { - OptimizedCallTargetLog.log(0, "perf warn", + logPerformanceWarning( String.format("CallTarget '%s' changed to '%s' during compilation for call node '%s'. Call node was not inlined.", decision.getTarget(), currentTarget, callNode), null); } diff -r 9eb112c9337d -r 43655130d0ab graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java Tue Sep 30 15:26:07 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java Tue Sep 30 19:00:46 2014 +0200 @@ -196,6 +196,16 @@ } } + if (TruffleCompilerOptions.PrintTrufflePerformanceWarnings.getValue()) { + int warnNodeCount = TruffleCompilerOptions.TrufflePerformanceWarningGraalNodeCount.getValue(); + if (graph.getNodeCount() > warnNodeCount) { + Map map = new LinkedHashMap<>(); + map.put("nodeCount", graph.getNodeCount()); + map.put("method", method.toString()); + OptimizedCallTargetLog.logPerformanceWarning(String.format("Method on fast path contains more than %d graal nodes.", warnNodeCount), map); + } + } + cache.put(key, graph); if (TruffleCompilerOptions.TraceTruffleCacheDetails.getValue()) { TTY.println(String.format("[truffle] added to graph cache method %s with %d nodes.", method, graph.getNodeCount())); diff -r 9eb112c9337d -r 43655130d0ab graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Tue Sep 30 15:26:07 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerOptions.java Tue Sep 30 19:00:46 2014 +0200 @@ -68,6 +68,9 @@ @Option(help = "Allow inlining of less hot candidates if tree size is small") public static final OptionValue TruffleInliningTrivialSize = new OptionValue<>(10); + @Option(help = "Defines the number of graal nodes that triggers a performance warning.") + public static final OptionValue TrufflePerformanceWarningGraalNodeCount = new OptionValue<>(1000); + @Option(help = "Enable call target splitting") public static final OptionValue TruffleSplitting = new OptionValue<>(true); @Option(help = "Experimental: Enable the new version of truffle splitting.")