Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: src/heap/gc-tracer.cc

Issue 578453003: Measure new space allocation throughput. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/gc-tracer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/gc-tracer.cc
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
index 035e3ee0c493c75fa1cc3f583c23ccd04da30358..85ee8aa22059447d7cf4c9f309a90ccb4d6adf00 100644
--- a/src/heap/gc-tracer.cc
+++ b/src/heap/gc-tracer.cc
@@ -19,6 +19,13 @@ static intptr_t CountTotalHolesSize(Heap* heap) {
}
+GCTracer::AllocationEvent::AllocationEvent(double duration,
+ intptr_t allocation_in_bytes) {
+ duration_ = duration;
+ allocation_in_bytes_ = allocation_in_bytes;
+}
+
+
GCTracer::Event::Event(Type type, const char* gc_reason,
const char* collector_reason)
: type(type),
@@ -80,7 +87,8 @@ GCTracer::GCTracer(Heap* heap)
cumulative_pure_incremental_marking_duration_(0.0),
longest_incremental_marking_step_(0.0),
cumulative_marking_duration_(0.0),
- cumulative_sweeping_duration_(0.0) {
+ cumulative_sweeping_duration_(0.0),
+ new_space_top_after_gc_(0) {
current_ = Event(Event::START, NULL, NULL);
current_.end_time = base::OS::TimeCurrentMillis();
previous_ = previous_mark_compactor_event_ = current_;
@@ -90,6 +98,13 @@ GCTracer::GCTracer(Heap* heap)
void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
const char* collector_reason) {
previous_ = current_;
+ double start_time = base::OS::TimeCurrentMillis();
+ if (new_space_top_after_gc_ != 0) {
+ AddNewSpaceAllocationTime(
+ start_time - previous_.end_time,
+ reinterpret_cast<intptr_t>((heap_->new_space()->top()) -
+ new_space_top_after_gc_));
+ }
if (current_.type == Event::MARK_COMPACTOR)
previous_mark_compactor_event_ = current_;
@@ -99,7 +114,7 @@ void GCTracer::Start(GarbageCollector collector, const char* gc_reason,
current_ = Event(Event::MARK_COMPACTOR, gc_reason, collector_reason);
}
- current_.start_time = base::OS::TimeCurrentMillis();
+ current_.start_time = start_time;
current_.start_object_size = heap_->SizeOfObjects();
current_.start_memory_size = heap_->isolate()->memory_allocator()->Size();
current_.start_holes_size = CountTotalHolesSize(heap_);
@@ -127,6 +142,8 @@ void GCTracer::Stop() {
current_.end_object_size = heap_->SizeOfObjects();
current_.end_memory_size = heap_->isolate()->memory_allocator()->Size();
current_.end_holes_size = CountTotalHolesSize(heap_);
+ new_space_top_after_gc_ =
+ reinterpret_cast<intptr_t>(heap_->new_space()->top());
if (current_.type == Event::SCAVENGER) {
current_.incremental_marking_steps =
@@ -184,6 +201,12 @@ void GCTracer::Stop() {
}
+void GCTracer::AddNewSpaceAllocationTime(double duration,
+ intptr_t allocation_in_bytes) {
+ allocation_events_.push_front(AllocationEvent(duration, allocation_in_bytes));
+}
+
+
void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) {
cumulative_incremental_marking_steps_++;
cumulative_incremental_marking_bytes_ += bytes;
@@ -294,6 +317,8 @@ void GCTracer::PrintNVP() const {
PrintF("nodes_promoted=%d ", heap_->nodes_promoted_);
PrintF("promotion_rate=%.1f%% ", heap_->promotion_rate_);
PrintF("semi_space_copy_rate=%.1f%% ", heap_->semi_space_copied_rate_);
+ PrintF("new_space_allocation_throughput=%d ",
+ NewSpaceAllocationThroughputInBytesPerMillisecond());
if (current_.type == Event::SCAVENGER) {
PrintF("steps_count=%d ", current_.incremental_marking_steps);
@@ -435,5 +460,21 @@ intptr_t GCTracer::MarkCompactSpeedInBytesPerMillisecond() const {
return static_cast<intptr_t>(bytes / durations);
}
+
+
+intptr_t GCTracer::NewSpaceAllocationThroughputInBytesPerMillisecond() const {
+ intptr_t bytes = 0;
+ double durations = 0.0;
+ AllocationEventBuffer::const_iterator iter = allocation_events_.begin();
+ while (iter != allocation_events_.end()) {
+ bytes += iter->allocation_in_bytes_;
+ durations += iter->duration_;
+ ++iter;
+ }
+
+ if (durations == 0.0) return 0;
+
+ return static_cast<intptr_t>(bytes / durations);
+}
}
} // namespace v8::internal
« no previous file with comments | « src/heap/gc-tracer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698