changeset 15639:19ec9885ce6e

added metric to count the input graph sizes for phases
author Doug Simon <doug.simon@oracle.com>
date Wed, 14 May 2014 12:37:39 +0200
parents 83c69954bbaa
children 2208a130d636
files graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java
diffstat 1 files changed, 32 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java	Wed May 14 11:19:38 2014 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/BasePhase.java	Wed May 14 12:37:39 2014 +0200
@@ -28,6 +28,7 @@
 import com.oracle.graal.debug.Debug.Scope;
 import com.oracle.graal.debug.DebugMemUseTracker.Closeable;
 import com.oracle.graal.debug.internal.*;
+import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 
 /**
@@ -39,9 +40,26 @@
 
     private CharSequence name;
 
-    private final DebugTimer phaseTimer;
-    private final DebugMetric phaseMetric;
-    private final DebugMemUseTracker phaseMemUseTracker;
+    /**
+     * Records time spent in {@link #apply(StructuredGraph, Object, boolean)}.
+     */
+    private final DebugTimer timer;
+
+    /**
+     * Counts calls to {@link #apply(StructuredGraph, Object, boolean)}.
+     */
+    private final DebugMetric executionCount;
+
+    /**
+     * Accumulates the {@linkplain Graph#getNodeCount() live node count} of all graphs sent to
+     * {@link #apply(StructuredGraph, Object, boolean)}.
+     */
+    private final DebugMetric inputNodesCount;
+
+    /**
+     * Records memory usage within {@link #apply(StructuredGraph, Object, boolean)}.
+     */
+    private final DebugMemUseTracker memUseTracker;
 
     private static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+");
 
@@ -51,17 +69,19 @@
     }
 
     protected BasePhase() {
-        phaseTimer = Debug.timer("PhaseTime_%s", getClass());
-        phaseMetric = Debug.metric("PhaseCount_%s", getClass());
-        phaseMemUseTracker = Debug.memUseTracker("PhaseMemUse_%s", getClass());
+        timer = Debug.timer("PhaseTime_%s", getClass());
+        executionCount = Debug.metric("PhaseCount_%s", getClass());
+        memUseTracker = Debug.memUseTracker("PhaseMemUse_%s", getClass());
+        inputNodesCount = Debug.metric("PhaseNodes_%s", getClass());
     }
 
     protected BasePhase(String name) {
         assert checkName(name);
         this.name = name;
-        phaseTimer = Debug.timer("PhaseTime_%s", getClass());
-        phaseMetric = Debug.metric("PhaseCount_%s", getClass());
-        phaseMemUseTracker = Debug.memUseTracker("PhaseMemUse_%s", getClass());
+        timer = Debug.timer("PhaseTime_%s", getClass());
+        executionCount = Debug.metric("PhaseCount_%s", getClass());
+        memUseTracker = Debug.memUseTracker("PhaseMemUse_%s", getClass());
+        inputNodesCount = Debug.metric("PhaseNodes_%s", getClass());
     }
 
     protected CharSequence getDetailedName() {
@@ -73,9 +93,10 @@
     }
 
     public final void apply(final StructuredGraph graph, final C context, final boolean dumpGraph) {
-        try (TimerCloseable a = phaseTimer.start(); Scope s = Debug.scope(getClass(), this); Closeable c = phaseMemUseTracker.start()) {
+        try (TimerCloseable a = timer.start(); Scope s = Debug.scope(getClass(), this); Closeable c = memUseTracker.start()) {
             BasePhase.this.run(graph, context);
-            phaseMetric.increment();
+            executionCount.increment();
+            inputNodesCount.add(graph.getNodeCount());
             if (dumpGraph && Debug.isDumpEnabled()) {
                 Debug.dump(graph, "After phase %s", getName());
             }