Reviewers: Erik Corry,
Description:
Extend --trace-gc to output amount of memory reserved for V8 heap.
This allows one to spot fragmentation issues just by looking at --trace-gc
output.
[email protected]
Please review this at https://chromiumcodereview.appspot.com/9316060/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/heap.h
M src/heap.cc
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index
ff978cf3b7f5f198165fcd01e5c82ca6b1ed3059..3b77714affc7a1ab07c4b6c77e74f613dedac62c
100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -6513,7 +6513,8 @@ static intptr_t CountTotalHolesSize() {
GCTracer::GCTracer(Heap* heap)
: start_time_(0.0),
- start_size_(0),
+ start_object_size_(0),
+ start_memory_size_(0),
gc_count_(0),
full_gc_count_(0),
allocated_since_last_gc_(0),
@@ -6522,7 +6523,8 @@ GCTracer::GCTracer(Heap* heap)
heap_(heap) {
if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return;
start_time_ = OS::TimeCurrentMillis();
- start_size_ = heap_->SizeOfObjects();
+ start_object_size_ = heap_->SizeOfObjects();
+ start_memory_size_ = heap_->isolate()->memory_allocator()->Size();
for (int i = 0; i < Scope::kNumberOfScopes; i++) {
scopes_[i] = 0;
@@ -6572,10 +6574,15 @@ GCTracer::~GCTracer() {
if (!FLAG_trace_gc_nvp) {
int external_time = static_cast<int>(scopes_[Scope::EXTERNAL]);
- PrintF("%s %.1f -> %.1f MB, ",
+ double end_memory_size_mb =
+ static_cast<double>(heap_->isolate()->memory_allocator()->Size())
/ MB;
+
+ PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ",
CollectorString(),
- static_cast<double>(start_size_) / MB,
- SizeOfHeapObjects());
+ static_cast<double>(start_object_size_) / MB,
+ static_cast<double>(start_memory_size_) / MB,
+ SizeOfHeapObjects(),
+ end_memory_size_mb);
if (external_time > 0) PrintF("%d / ", external_time);
PrintF("%d ms", time);
@@ -6629,7 +6636,7 @@ GCTracer::~GCTracer() {
PrintF("misc_compaction=%d ",
static_cast<int>(scopes_[Scope::MC_UPDATE_MISC_POINTERS]));
- PrintF("total_size_before=%" V8_PTR_PREFIX "d ", start_size_);
+ PrintF("total_size_before=%" V8_PTR_PREFIX "d ", start_object_size_);
PrintF("total_size_after=%" V8_PTR_PREFIX "d ",
heap_->SizeOfObjects());
PrintF("holes_size_before=%" V8_PTR_PREFIX "d ",
in_free_list_or_wasted_before_gc_);
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
a2702d35432df227d2ead5faa7ca3a1220603fb9..cdc693369aa65a083aae8a9f69a65433b825d409
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -2445,9 +2445,17 @@ class GCTracer BASE_EMBEDDED {
return (static_cast<double>(HEAP->SizeOfObjects())) / MB;
}
- double start_time_; // Timestamp set in the constructor.
- intptr_t start_size_; // Size of objects in heap set in constructor.
- GarbageCollector collector_; // Type of collector.
+ // Timestamp set in the constructor.
+ double start_time_;
+
+ // Size of objects in heap set in constructor.
+ intptr_t start_object_size_;
+
+ // Size of memory allocated from OS set in constructor.
+ intptr_t start_memory_size_;
+
+ // Type of collector.
+ GarbageCollector collector_;
// A count (including this one, e.g. the first collection is 1) of the
// number of garbage collections.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev