Revision: 10584
Author:   [email protected]
Date:     Thu Feb  2 03:47:23 2012
Log:      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]

Review URL: https://chromiumcodereview.appspot.com/9316060
http://code.google.com/p/v8/source/detail?r=10584

Modified:
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/heap.h

=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Jan 31 05:33:44 2012
+++ /branches/bleeding_edge/src/heap.cc Thu Feb  2 03:47:23 2012
@@ -6513,7 +6513,8 @@

 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 @@
       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 @@
   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 @@
     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_);
=======================================
--- /branches/bleeding_edge/src/heap.h  Fri Jan 27 07:53:24 2012
+++ /branches/bleeding_edge/src/heap.h  Thu Feb  2 03:47:23 2012
@@ -2387,9 +2387,17 @@
   // Returns size of object in heap (in MB).
   inline double SizeOfHeapObjects();

-  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

Reply via email to