Revision: 23994
Author: [email protected]
Date: Wed Sep 17 08:50:57 2014 UTC
Log: Measure new space allocation throughput.
BUG=
[email protected]
Review URL: https://codereview.chromium.org/578453003
https://code.google.com/p/v8/source/detail?r=23994
Modified:
/branches/bleeding_edge/src/heap/gc-tracer.cc
/branches/bleeding_edge/src/heap/gc-tracer.h
=======================================
--- /branches/bleeding_edge/src/heap/gc-tracer.cc Thu Aug 21 14:42:22 2014
UTC
+++ /branches/bleeding_edge/src/heap/gc-tracer.cc Wed Sep 17 08:50:57 2014
UTC
@@ -17,6 +17,13 @@
}
return holes_size;
}
+
+
+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,
@@ -80,7 +87,8 @@
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 @@
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 @@
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 @@
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 =
@@ -182,6 +199,12 @@
heap_->PrintShortHeapStatistics();
}
}
+
+
+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) {
@@ -294,6 +317,8 @@
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);
@@ -430,6 +455,22 @@
iter->pure_incremental_marking_duration;
++iter;
}
+
+ if (durations == 0.0) return 0;
+
+ 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;
=======================================
--- /branches/bleeding_edge/src/heap/gc-tracer.h Thu Aug 21 14:42:22 2014
UTC
+++ /branches/bleeding_edge/src/heap/gc-tracer.h Wed Sep 17 08:50:57 2014
UTC
@@ -129,6 +129,22 @@
};
+ class AllocationEvent {
+ public:
+ // Default constructor leaves the event uninitialized.
+ AllocationEvent() {}
+
+ AllocationEvent(double duration, intptr_t allocation_in_bytes);
+
+ // Time spent in the mutator during the end of the last garbage
collection
+ // to the beginning of the next garbage collection.
+ double duration_;
+
+ // Memory allocated in the new space during the end of the last garbage
+ // collection to the beginning of the next garbage collection.
+ intptr_t allocation_in_bytes_;
+ };
+
class Event {
public:
enum Type { SCAVENGER = 0, MARK_COMPACTOR = 1, START = 2 };
@@ -223,6 +239,8 @@
typedef RingBuffer<Event, kRingBufferMaxSize> EventBuffer;
+ typedef RingBuffer<AllocationEvent, kRingBufferMaxSize>
AllocationEventBuffer;
+
explicit GCTracer(Heap* heap);
// Start collecting data.
@@ -232,6 +250,9 @@
// Stop collecting data and print results.
void Stop();
+ // Log an allocation throughput event.
+ void AddNewSpaceAllocationTime(double duration, intptr_t
allocation_in_bytes);
+
// Log an incremental marking step.
void AddIncrementalMarkingStep(double duration, intptr_t bytes);
@@ -297,6 +318,10 @@
// Returns 0 if no events have been recorded.
intptr_t MarkCompactSpeedInBytesPerMillisecond() const;
+ // Allocation throughput in the new space in bytes/millisecond.
+ // Returns 0 if no events have been recorded.
+ intptr_t NewSpaceAllocationThroughputInBytesPerMillisecond() const;
+
private:
// Print one detailed trace line in name=value format.
// TODO(ernstm): Move to Heap.
@@ -331,6 +356,9 @@
// RingBuffers for MARK_COMPACTOR events.
EventBuffer mark_compactor_events_;
+ // RingBuffer for allocation events.
+ AllocationEventBuffer allocation_events_;
+
// Cumulative number of incremental marking steps since creation of
tracer.
int cumulative_incremental_marking_steps_;
@@ -361,6 +389,10 @@
// all sweeping operations performed on the main thread.
double cumulative_sweeping_duration_;
+ // Holds the new space top pointer recorded at the end of the last
garbage
+ // collection.
+ intptr_t new_space_top_after_gc_;
+
DISALLOW_COPY_AND_ASSIGN(GCTracer);
};
}
--
--
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.