Commits

David Mandelin  committed 977e5dd

initial reason support for events

  • Participants
  • Parent commits 444461b

Comments (0)

Files changed (2)

File scripts/vis.py

 
     # This method is actually faster than reading it all into a buffer and decoding
     # from there.
+    pos = f.tell()
+    f.seek(0, os.SEEK_END)
+    n = (f.tell() - pos) / 10
+    f.seek(pos)
+
+    dot = n / 80;
+
     transitions = []
     t0 = clock()
-    while True:
-        raw = f.read(9)
-        if len(raw) < 9: break
+    for i in range(n):
+        if i % dot == 0:
+            sys.stdout.write('.')
+            sys.stdout.flush()
+        raw = f.read(10)
         s = struct.unpack_from('B', raw)[0]
-        t = struct.unpack_from('Q', raw, 1)[0]
-        transitions.append((s, t))
+        r = struct.unpack_from('B', raw, 1)[0]
+        t = struct.unpack_from('Q', raw, 2)[0]
+        transitions.append((s, r, t))
     t1 = clock()
 
-    print 'read time: ', (t1-t0)
+    print '\nread time: ', (t1-t0)
     
     return Data(duration, summary, transitions)
 
         color = [ 0, 0, 0 ]
         tx = t0
         while ti < len(ts):
-            state, time = ts[ti];
+            state, reason, time = ts[ti];
             # States past this limit are actually events rather than state transitions
             if state >= event_start:
                 events.append((x, y))

File src/binlog.cpp

  *       8M              M uint64: rdtsc time totals by state, from 0 to S_COUNT-1
  *       9N              N 9-byte packed records (X = 17+9N)
  *                         Each record represents a transition out of an activity.
- *             0                 byte:   VM state before transition
+ *             1                 byte:   VM state before transition
+ *             1                 byte:   reason code (used only for events)
  *             8                 uint64: rdtsc timestamp
  */
 
     }
   }
 
-  void write(int state, uint64 time) {
+  void write(int state, int reason, uint64 time) {
     if (print_history) {
       putc(state, history_file);
+      putc(reason, history_file);
       uint64 t = time - t0;
       fwrite(&t, sizeof(t), 1, history_file);
     }
     uint64 dt = rec1.t - rec0.t;
     state_summary[rec0.s] += dt;
 
-    write(rec0.s, rec1.t);
+    write(rec0.s, 0, rec1.t);
 
     // Transition to interpreter
     if (rec0.s != S_INTERP && rec1.s == S_INTERP) {
   void enter(const Record& rec) {
     // State values >= S_COUNT represent events instead of states.
     if (rec.s >= S_COUNT) {
-      write(rec.s, rec.t);
+      write(rec.s, rec.r, rec.t);
     } else {
 	if (stack.size() == 0) {
 	  t0 = rec.t;