Revision: 22777
Author:   [email protected]
Date:     Fri Aug  1 07:41:46 2014 UTC
Log:      Clean-up and repair cumulative marking and sweeping time stats.

BUG=
[email protected]

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

Modified:
 /branches/bleeding_edge/src/gc-tracer.cc
 /branches/bleeding_edge/src/gc-tracer.h
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h
 /branches/bleeding_edge/src/incremental-marking.cc
 /branches/bleeding_edge/src/mark-compact.cc

=======================================
--- /branches/bleeding_edge/src/gc-tracer.cc    Fri Aug  1 07:34:49 2014 UTC
+++ /branches/bleeding_edge/src/gc-tracer.cc    Fri Aug  1 07:41:46 2014 UTC
@@ -75,7 +75,9 @@
       cumulative_incremental_marking_steps_(0),
       cumulative_incremental_marking_bytes_(0),
       cumulative_incremental_marking_duration_(0.0),
-      longest_incremental_marking_step_(0.0) {
+      longest_incremental_marking_step_(0.0),
+      cumulative_marking_duration_(0.0),
+      cumulative_sweeping_duration_(0.0) {
   current_ = Event(Event::START, NULL, NULL);
   current_.end_time = base::OS::TimeCurrentMillis();
   previous_ = previous_mark_compactor_event_ = current_;
@@ -174,6 +176,7 @@
   cumulative_incremental_marking_duration_ += duration;
   longest_incremental_marking_step_ =
       Max(longest_incremental_marking_step_, duration);
+  cumulative_marking_duration_ += duration;
 }


=======================================
--- /branches/bleeding_edge/src/gc-tracer.h     Fri Aug  1 07:34:49 2014 UTC
+++ /branches/bleeding_edge/src/gc-tracer.h     Fri Aug  1 07:41:46 2014 UTC
@@ -219,6 +219,26 @@

   // Log an incremental marking step.
   void AddIncrementalMarkingStep(double duration, intptr_t bytes);
+
+  // Log time spent in marking.
+  void AddMarkingTime(double duration) {
+    cumulative_marking_duration_ += duration;
+  }
+
+  // Time spent in marking.
+  double cumulative_marking_duration() const {
+    return cumulative_marking_duration_;
+  }
+
+  // Log time spent in sweeping on main thread.
+  void AddSweepingTime(double duration) {
+    cumulative_sweeping_duration_ += duration;
+  }
+
+  // Time spent in sweeping on main thread.
+  double cumulative_sweeping_duration() const {
+    return cumulative_sweeping_duration_;
+  }

// Compute the mean duration of the last scavenger events. Returns 0 if no
   // events have been recorded.
@@ -301,6 +321,19 @@
   // Longest incremental marking step since start of marking.
   double longest_incremental_marking_step_;

+  // Total marking time.
+  // This timer is precise when run with --print-cumulative-gc-stat
+  double cumulative_marking_duration_;
+
+  // Total sweeping time on the main thread.
+  // This timer is precise when run with --print-cumulative-gc-stat
+  // TODO(hpayer): Account for sweeping time on sweeper threads. Add a
+  // different field for that.
+  // TODO(hpayer): This timer right now just holds the sweeping time
+  // of the initial atomic sweeping pause. Make sure that it accumulates
+  // all sweeping operations performed on the main thread.
+  double cumulative_sweeping_duration_;
+
   DISALLOW_COPY_AND_ASSIGN(GCTracer);
 };
 }
=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Jul 29 17:02:52 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Fri Aug  1 07:41:46 2014 UTC
@@ -5206,8 +5206,8 @@
     PrintF("min_in_mutator=%.1f ", get_min_in_mutator());
     PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ",
            get_max_alive_after_gc());
-    PrintF("total_marking_time=%.1f ", marking_time());
-    PrintF("total_sweeping_time=%.1f ", sweeping_time());
+ PrintF("total_marking_time=%.1f ", tracer_.cumulative_sweeping_duration()); + PrintF("total_sweeping_time=%.1f ", tracer_.cumulative_sweeping_duration());
     PrintF("\n\n");
   }

=======================================
--- /branches/bleeding_edge/src/heap.h  Tue Jul 29 17:02:52 2014 UTC
+++ /branches/bleeding_edge/src/heap.h  Fri Aug  1 07:41:46 2014 UTC
@@ -1245,24 +1245,6 @@

   // Returns minimal interval between two subsequent collections.
   double get_min_in_mutator() { return min_in_mutator_; }
-
-  // TODO(hpayer): remove, should be handled by GCTracer
-  void AddMarkingTime(double marking_time) {
-    marking_time_ += marking_time;
-  }
-
-  double marking_time() const {
-    return marking_time_;
-  }
-
-  // TODO(hpayer): remove, should be handled by GCTracer
-  void AddSweepingTime(double sweeping_time) {
-    sweeping_time_ += sweeping_time;
-  }
-
-  double sweeping_time() const {
-    return sweeping_time_;
-  }

   MarkCompactCollector* mark_compact_collector() {
     return &mark_compact_collector_;
=======================================
--- /branches/bleeding_edge/src/incremental-marking.cc Fri Aug 1 07:34:49 2014 UTC +++ /branches/bleeding_edge/src/incremental-marking.cc Fri Aug 1 07:41:46 2014 UTC
@@ -731,7 +731,7 @@
     if (FLAG_trace_incremental_marking || FLAG_print_cumulative_gc_stat) {
       double end = base::OS::TimeCurrentMillis();
       double delta = end - start;
-      heap_->AddMarkingTime(delta);
+      heap_->tracer()->AddMarkingTime(delta);
       if (FLAG_trace_incremental_marking) {
         PrintF("[IncrementalMarking] Complete (hurry), spent %d ms.\n",
                static_cast<int>(delta));
@@ -963,7 +963,6 @@
     // when we just started incremental marking. In these cases we did not
     // process the marking deque.
     heap_->tracer()->AddIncrementalMarkingStep(duration, bytes_processed);
-    heap_->AddMarkingTime(duration);
   }
 }

=======================================
--- /branches/bleeding_edge/src/mark-compact.cc Wed Jul 30 08:55:25 2014 UTC
+++ /branches/bleeding_edge/src/mark-compact.cc Fri Aug  1 07:41:46 2014 UTC
@@ -2291,6 +2291,10 @@

 void MarkCompactCollector::MarkLiveObjects() {
   GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_MARK);
+  double start_time = 0.0;
+  if (FLAG_print_cumulative_gc_stat) {
+    start_time = base::OS::TimeCurrentMillis();
+  }
   // The recursive GC marker detects when it is nearing stack overflow,
   // and switches to a different marking system.  JS interrupts interfere
   // with the C stack limit check.
@@ -2395,6 +2399,10 @@
   ProcessEphemeralMarking(&root_visitor);

   AfterMarking();
+
+  if (FLAG_print_cumulative_gc_stat) {
+ heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() - start_time);
+  }
 }


@@ -3283,11 +3291,6 @@
ASSERT((p->skip_list() == NULL) || (skip_list_mode == REBUILD_SKIP_LIST));
   ASSERT(parallelism == MarkCompactCollector::SWEEP_ON_MAIN_THREAD ||
          sweeping_mode == SWEEP_ONLY);
-
-  double start_time = 0.0;
-  if (FLAG_print_cumulative_gc_stat) {
-    start_time = base::OS::TimeCurrentMillis();
-  }

   Address free_start = p->area_start();
ASSERT(reinterpret_cast<intptr_t>(free_start) % (32 * kPointerSize) == 0);
@@ -3359,9 +3362,6 @@
 #endif
   }
   p->ResetLiveBytes();
-  if (FLAG_print_cumulative_gc_stat) {
- space->heap()->AddSweepingTime(base::OS::TimeCurrentMillis() - start_time);
-  }

   if (parallelism == MarkCompactCollector::SWEEP_IN_PARALLEL) {
     // When concurrent sweeping is active, the page will be marked after
@@ -4308,6 +4308,11 @@

 void MarkCompactCollector::SweepSpaces() {
   GCTracer::Scope gc_scope(heap()->tracer(), GCTracer::Scope::MC_SWEEP);
+  double start_time = 0.0;
+  if (FLAG_print_cumulative_gc_stat) {
+    start_time = base::OS::TimeCurrentMillis();
+  }
+
 #ifdef DEBUG
   state_ = SWEEP_SPACES;
 #endif
@@ -4372,6 +4377,11 @@

   // Deallocate evacuated candidate pages.
   ReleaseEvacuationCandidates();
+
+  if (FLAG_print_cumulative_gc_stat) {
+    heap_->tracer()->AddSweepingTime(base::OS::TimeCurrentMillis() -
+                                     start_time);
+  }
 }


--
--
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/d/optout.

Reply via email to