Revision: 15462
Author:   [email protected]
Date:     Wed Jul  3 03:10:27 2013
Log:      Log deopts with --log-timer-events.

[email protected]
BUG=

Review URL: https://codereview.chromium.org/17599007
http://code.google.com/p/v8/source/detail?r=15462

Modified:
 /branches/bleeding_edge/src/deoptimizer.cc
 /branches/bleeding_edge/src/log.cc
 /branches/bleeding_edge/src/log.h
 /branches/bleeding_edge/tools/profviz/composer.js

=======================================
--- /branches/bleeding_edge/src/deoptimizer.cc  Wed Jun 26 06:36:16 2013
+++ /branches/bleeding_edge/src/deoptimizer.cc  Wed Jul  3 03:10:27 2013
@@ -714,6 +714,10 @@

   // Print some helpful diagnostic information.
   int64_t start = OS::Ticks();
+  if (FLAG_log_timer_events &&
+      compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) {
+    LOG(isolate(), CodeDeoptEvent(compiled_code_));
+  }
   if (trace_) {
     PrintF("[deoptimizing (DEOPT %s): begin 0x%08" V8PRIxPTR " ",
            MessageFor(bailout_type_),
=======================================
--- /branches/bleeding_edge/src/log.cc  Tue Jul  2 08:44:30 2013
+++ /branches/bleeding_edge/src/log.cc  Wed Jul  3 03:10:27 2013
@@ -635,6 +635,16 @@
              end);
   msg.WriteToLogFile();
 }
+
+
+void Logger::CodeDeoptEvent(Code* code) {
+  if (!log_->IsEnabled()) return;
+  ASSERT(FLAG_log_internal_timer_events);
+  LogMessageBuilder msg(this);
+  int since_epoch = static_cast<int>(OS::Ticks() - epoch_);
+  msg.Append("code-deopt,%ld,%d\n", since_epoch, code->CodeSize());
+  msg.WriteToLogFile();
+}


 void Logger::TimerEvent(StartEnd se, const char* name) {
=======================================
--- /branches/bleeding_edge/src/log.h   Mon Jun 24 05:55:19 2013
+++ /branches/bleeding_edge/src/log.h   Wed Jul  3 03:10:27 2013
@@ -293,6 +293,8 @@
   // ==== Events logged by --log-timer-events. ====
   enum StartEnd { START, END };

+  void CodeDeoptEvent(Code* code);
+
   void TimerEvent(StartEnd se, const char* name);

   static void EnterExternal(Isolate* isolate);
=======================================
--- /branches/bleeding_edge/tools/profviz/composer.js Tue Jul 2 08:34:28 2013 +++ /branches/bleeding_edge/tools/profviz/composer.js Wed Jul 3 03:10:27 2013
@@ -41,7 +41,9 @@
var kStackFrameWidth = 0.1; // Width of the lower stack frame lines.
   var kGapWidth = 0.05;             // Gap between stack frame lines.

- var kY1Offset = 10; // Offset for stack frame vs. event lines. + var kY1Offset = 11; // Offset for stack frame vs. event lines.
+  var kDeoptRow = 7;                // Row displaying deopts.
+  var kMaxDeoptLength = 4;          // Draw size of the largest deopt.
   var kPauseLabelPadding = 5;       // Padding for pause time labels.
   var kNumPauseLabels = 7;          // Number of biggest pauses to label.
   var kCodeKindLabelPadding = 100;  // Padding for code kind labels.
@@ -52,6 +54,9 @@
   var kNumThreads = 2;              // Number of threads.
   var kExecutionThreadId = 0;       // ID of main thread.

+  // Init values.
+  var num_timer_event = kY1Offset + 0.5;
+
   // Data structures.
   function TimerEvent(label, color, pause, thread_id) {
     assert(thread_id >= 0 && thread_id < kNumThreads, "invalid thread id");
@@ -72,9 +77,13 @@
   }

   function Range(start, end) {
-    // Everthing here are in milliseconds.
-    this.start = start;
-    this.end = end;
+    this.start = start;  // In milliseconds.
+    this.end = end;      // In milliseconds.
+  }
+
+  function Deopt(time, size) {
+    this.time = time;  // In milliseconds.
+    this.size = size;  // In bytes.
   }

   Range.prototype.duration = function() { return this.end - this.start; }
@@ -82,9 +91,6 @@
   function Tick(tick) {
     this.tick = tick;
   }
-
-  // Init values.
-  var num_timer_event = kY1Offset + 0.5;

   var TimerEvents = {
       'V8.Execute':
@@ -127,6 +133,7 @@

   var code_map = new CodeMap();
   var execution_pauses = [];
+  var deopts = [];
   var event_stack = [];
   var last_time_stamp = [];
   for (var i = 0; i < kNumThreads; i++) {
@@ -312,6 +319,10 @@
       code_map.deleteCode(address);
     };

+    var processCodeDeoptEvent = function(time, size) {
+      deopts.push(new Deopt(time, size));
+    }
+
     var processSharedLibrary = function(name, start, end) {
       var code_entry = new CodeMap.CodeEntry(end - start, name);
       code_entry.kind = -3;  // External code kind.
@@ -352,6 +363,8 @@
                             processor: processCodeMoveEvent },
         'code-delete':    { parsers: [parseInt],
                             processor: processCodeDeleteEvent },
+        'code-deopt':     { parsers: [parseTimeStamp, parseInt],
+                            processor: processCodeDeoptEvent },
         'tick':           { parsers: [parseInt, parseInt, parseTimeStamp,
                                       null, null, parseInt, 'var-args'],
                             processor: processTickEvent }
@@ -423,17 +436,26 @@
     output("set style rect fs solid 1 noborder");
     output("set style line 1 lt 1 lw 1 lc rgb \"#000000\"");
     output("set border 15 lw 0.2");  // Draw thin border box.
+    output("set style line 2 lt 1 lw 1 lc rgb \"#9944CC\"");
     output("set xtics out nomirror");
     output("unset key");

-    function DrawBar(row, color, start, end, width) {
+    function DrawBarBase(color, start, end, top, bottom) {
       obj_index++;
       command = "set object " + obj_index + " rect";
-      command += " from " + start + ", " + (row - width);
-      command += " to " + end + ", " + (row + width);
+      command += " from " + start + ", " + top;
+      command += " to " + end + ", " + bottom;
       command += " fc rgb \"" + color + "\"";
       output(command);
     }
+
+    function DrawBar(row, color, start, end, width) {
+      DrawBarBase(color, start, end, row + width, row - width);
+    }
+
+    function DrawHalfBar(row, color, start, end, width) {
+      DrawBarBase(color, start, end, row, row - width);
+    }

     var percentages = {};
     var total = 0;
@@ -446,6 +468,17 @@
             .reduce(function(a, b) { return a + b; }, 0);
percentages[name] = (sum / (range_end - range_start) * 100).toFixed(1);
     }
+
+    // Plot deopts.
+    deopts.sort(function(a, b) { return b.size - a.size; });
+    var max_deopt_size = deopts.length > 0 ? deopts[0].size : Infinity;
+
+    for (var i = 0; i < deopts.length; i++) {
+      var deopt = deopts[i];
+      DrawHalfBar(kDeoptRow, "#9944CC", deopt.time,
+                  deopt.time + 10 * pause_tolerance,
+                  deopt.size / max_deopt_size * kMaxDeoptLength);
+    }

     // Name Y-axis.
     var ytics = [];
@@ -459,6 +492,8 @@
     ytics.push('"top ' + kStackFrames + ' js stack frames"' + ' ' +
                (kY1Offset - 2));
     ytics.push('"pause times" 0');
+    ytics.push('"max deopt size: ' + (max_deopt_size / 1024).toFixed(1) +
+               ' kB" ' + kDeoptRow);
     output("set ytics out nomirror (" + ytics.join(', ') + ")");

     // Plot timeline.

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to