Reviewers: ernstm,
Description:
Clean-up and repair cumulative marking and sweeping time stats.
BUG=
Please review this at https://codereview.chromium.org/432743002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+57, -31 lines):
M src/gc-tracer.h
M src/gc-tracer.cc
M src/heap.h
M src/heap.cc
M src/incremental-marking.cc
M src/mark-compact.cc
Index: src/gc-tracer.cc
diff --git a/src/gc-tracer.cc b/src/gc-tracer.cc
index
74a2aa873f1cb635ad6a2401c01cc4640db7f1c0..56b359df37e01108fd58c0f1e530520e5da38bea
100644
--- a/src/gc-tracer.cc
+++ b/src/gc-tracer.cc
@@ -75,7 +75,9 @@ GCTracer::GCTracer(Heap* heap)
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 @@ void GCTracer::AddIncrementalMarkingStep(double
duration, intptr_t bytes) {
cumulative_incremental_marking_duration_ += duration;
longest_incremental_marking_step_ =
Max(longest_incremental_marking_step_, duration);
+ cumulative_marking_duration_ += duration;
}
Index: src/gc-tracer.h
diff --git a/src/gc-tracer.h b/src/gc-tracer.h
index
0f4f135256ecc6ebd0ca0ea68ba1b68bf299108a..2354b3c203bff9fa6699a4833ebd7e4791571820
100644
--- a/src/gc-tracer.h
+++ b/src/gc-tracer.h
@@ -220,6 +220,26 @@ class GCTracer BASE_EMBEDDED {
// 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.
+ 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.
double MeanScavengerDuration() const {
@@ -301,6 +321,18 @@ class GCTracer BASE_EMBEDDED {
// 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.
+ double cumulative_sweeping_duration_;
+
DISALLOW_COPY_AND_ASSIGN(GCTracer);
};
}
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
67ee043e0b1168d49e5fef8914fc9535cc575600..8f06e9c0a428e1315fa793998e4708c31dc3e1af
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -5206,8 +5206,8 @@ void Heap::TearDown() {
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");
}
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
587b67bdf064c771de14f9b08bb9d839773c5b56..f143cced6ebaa75db3e967b5e81301b50400cbdc
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1246,24 +1246,6 @@ class Heap {
// 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_;
}
Index: src/incremental-marking.cc
diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc
index
0ab9a002452e94aa7846816d14c73e9c4f349b7e..1651234d0f827d5a367455738ed40955d9d1ef3e
100644
--- a/src/incremental-marking.cc
+++ b/src/incremental-marking.cc
@@ -729,7 +729,7 @@ void IncrementalMarking::Hurry() {
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));
@@ -957,7 +957,6 @@ void IncrementalMarking::Step(intptr_t allocated_bytes,
double end = base::OS::TimeCurrentMillis();
double duration = (end - start);
heap_->tracer()->AddIncrementalMarkingStep(duration, allocated_bytes);
- heap_->AddMarkingTime(duration);
}
}
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
f75db472d2b53cb16279e61854b1cd2c551e083a..9dbadacfb86b49785a7c78c43c8b5087f555fbc8
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -2291,6 +2291,10 @@ void
MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
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 @@ void MarkCompactCollector::MarkLiveObjects() {
ProcessEphemeralMarking(&root_visitor);
AfterMarking();
+
+ if (FLAG_print_cumulative_gc_stat) {
+ heap_->tracer()->AddMarkingTime(base::OS::TimeCurrentMillis() -
start_time);
+ }
}
@@ -3284,11 +3292,6 @@ static int SweepPrecisely(PagedSpace* space,
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);
int offsets[16];
@@ -3359,9 +3362,6 @@ static int SweepPrecisely(PagedSpace* space,
#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 @@ static bool ShouldWaitForSweeperThreads(
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 @@ void MarkCompactCollector::SweepSpaces() {
// 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.