| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/heap/gc-tracer.h" | 7 #include "src/heap/gc-tracer.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 start_memory_size(0), | 31 start_memory_size(0), |
| 32 end_memory_size(0), | 32 end_memory_size(0), |
| 33 start_holes_size(0), | 33 start_holes_size(0), |
| 34 end_holes_size(0), | 34 end_holes_size(0), |
| 35 cumulative_incremental_marking_steps(0), | 35 cumulative_incremental_marking_steps(0), |
| 36 incremental_marking_steps(0), | 36 incremental_marking_steps(0), |
| 37 cumulative_incremental_marking_bytes(0), | 37 cumulative_incremental_marking_bytes(0), |
| 38 incremental_marking_bytes(0), | 38 incremental_marking_bytes(0), |
| 39 cumulative_incremental_marking_duration(0.0), | 39 cumulative_incremental_marking_duration(0.0), |
| 40 incremental_marking_duration(0.0), | 40 incremental_marking_duration(0.0), |
| 41 cumulative_pure_incremental_marking_duration(0.0), |
| 42 pure_incremental_marking_duration(0.0), |
| 41 longest_incremental_marking_step(0.0) { | 43 longest_incremental_marking_step(0.0) { |
| 42 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | 44 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { |
| 43 scopes[i] = 0; | 45 scopes[i] = 0; |
| 44 } | 46 } |
| 45 } | 47 } |
| 46 | 48 |
| 47 | 49 |
| 48 const char* GCTracer::Event::TypeName(bool short_name) const { | 50 const char* GCTracer::Event::TypeName(bool short_name) const { |
| 49 switch (type) { | 51 switch (type) { |
| 50 case SCAVENGER: | 52 case SCAVENGER: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 68 } | 70 } |
| 69 return "Unknown Event Type"; | 71 return "Unknown Event Type"; |
| 70 } | 72 } |
| 71 | 73 |
| 72 | 74 |
| 73 GCTracer::GCTracer(Heap* heap) | 75 GCTracer::GCTracer(Heap* heap) |
| 74 : heap_(heap), | 76 : heap_(heap), |
| 75 cumulative_incremental_marking_steps_(0), | 77 cumulative_incremental_marking_steps_(0), |
| 76 cumulative_incremental_marking_bytes_(0), | 78 cumulative_incremental_marking_bytes_(0), |
| 77 cumulative_incremental_marking_duration_(0.0), | 79 cumulative_incremental_marking_duration_(0.0), |
| 80 cumulative_pure_incremental_marking_duration_(0.0), |
| 78 longest_incremental_marking_step_(0.0), | 81 longest_incremental_marking_step_(0.0), |
| 79 cumulative_marking_duration_(0.0), | 82 cumulative_marking_duration_(0.0), |
| 80 cumulative_sweeping_duration_(0.0) { | 83 cumulative_sweeping_duration_(0.0) { |
| 81 current_ = Event(Event::START, NULL, NULL); | 84 current_ = Event(Event::START, NULL, NULL); |
| 82 current_.end_time = base::OS::TimeCurrentMillis(); | 85 current_.end_time = base::OS::TimeCurrentMillis(); |
| 83 previous_ = previous_mark_compactor_event_ = current_; | 86 previous_ = previous_mark_compactor_event_ = current_; |
| 84 } | 87 } |
| 85 | 88 |
| 86 | 89 |
| 87 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, | 90 void GCTracer::Start(GarbageCollector collector, const char* gc_reason, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 100 current_.start_object_size = heap_->SizeOfObjects(); | 103 current_.start_object_size = heap_->SizeOfObjects(); |
| 101 current_.start_memory_size = heap_->isolate()->memory_allocator()->Size(); | 104 current_.start_memory_size = heap_->isolate()->memory_allocator()->Size(); |
| 102 current_.start_holes_size = CountTotalHolesSize(heap_); | 105 current_.start_holes_size = CountTotalHolesSize(heap_); |
| 103 | 106 |
| 104 current_.cumulative_incremental_marking_steps = | 107 current_.cumulative_incremental_marking_steps = |
| 105 cumulative_incremental_marking_steps_; | 108 cumulative_incremental_marking_steps_; |
| 106 current_.cumulative_incremental_marking_bytes = | 109 current_.cumulative_incremental_marking_bytes = |
| 107 cumulative_incremental_marking_bytes_; | 110 cumulative_incremental_marking_bytes_; |
| 108 current_.cumulative_incremental_marking_duration = | 111 current_.cumulative_incremental_marking_duration = |
| 109 cumulative_incremental_marking_duration_; | 112 cumulative_incremental_marking_duration_; |
| 113 current_.cumulative_pure_incremental_marking_duration = |
| 114 cumulative_pure_incremental_marking_duration_; |
| 110 current_.longest_incremental_marking_step = longest_incremental_marking_step_; | 115 current_.longest_incremental_marking_step = longest_incremental_marking_step_; |
| 111 | 116 |
| 112 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { | 117 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { |
| 113 current_.scopes[i] = 0; | 118 current_.scopes[i] = 0; |
| 114 } | 119 } |
| 115 } | 120 } |
| 116 | 121 |
| 117 | 122 |
| 118 void GCTracer::Stop() { | 123 void GCTracer::Stop() { |
| 119 current_.end_time = base::OS::TimeCurrentMillis(); | 124 current_.end_time = base::OS::TimeCurrentMillis(); |
| 120 current_.end_object_size = heap_->SizeOfObjects(); | 125 current_.end_object_size = heap_->SizeOfObjects(); |
| 121 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); | 126 current_.end_memory_size = heap_->isolate()->memory_allocator()->Size(); |
| 122 current_.end_holes_size = CountTotalHolesSize(heap_); | 127 current_.end_holes_size = CountTotalHolesSize(heap_); |
| 123 | 128 |
| 124 if (current_.type == Event::SCAVENGER) { | 129 if (current_.type == Event::SCAVENGER) { |
| 125 current_.incremental_marking_steps = | 130 current_.incremental_marking_steps = |
| 126 current_.cumulative_incremental_marking_steps - | 131 current_.cumulative_incremental_marking_steps - |
| 127 previous_.cumulative_incremental_marking_steps; | 132 previous_.cumulative_incremental_marking_steps; |
| 128 current_.incremental_marking_bytes = | 133 current_.incremental_marking_bytes = |
| 129 current_.cumulative_incremental_marking_bytes - | 134 current_.cumulative_incremental_marking_bytes - |
| 130 previous_.cumulative_incremental_marking_bytes; | 135 previous_.cumulative_incremental_marking_bytes; |
| 131 current_.incremental_marking_duration = | 136 current_.incremental_marking_duration = |
| 132 current_.cumulative_incremental_marking_duration - | 137 current_.cumulative_incremental_marking_duration - |
| 133 previous_.cumulative_incremental_marking_duration; | 138 previous_.cumulative_incremental_marking_duration; |
| 139 current_.pure_incremental_marking_duration = |
| 140 current_.cumulative_pure_incremental_marking_duration - |
| 141 previous_.cumulative_pure_incremental_marking_duration; |
| 134 scavenger_events_.push_front(current_); | 142 scavenger_events_.push_front(current_); |
| 135 } else { | 143 } else { |
| 136 current_.incremental_marking_steps = | 144 current_.incremental_marking_steps = |
| 137 current_.cumulative_incremental_marking_steps - | 145 current_.cumulative_incremental_marking_steps - |
| 138 previous_mark_compactor_event_.cumulative_incremental_marking_steps; | 146 previous_mark_compactor_event_.cumulative_incremental_marking_steps; |
| 139 current_.incremental_marking_bytes = | 147 current_.incremental_marking_bytes = |
| 140 current_.cumulative_incremental_marking_bytes - | 148 current_.cumulative_incremental_marking_bytes - |
| 141 previous_mark_compactor_event_.cumulative_incremental_marking_bytes; | 149 previous_mark_compactor_event_.cumulative_incremental_marking_bytes; |
| 142 current_.incremental_marking_duration = | 150 current_.incremental_marking_duration = |
| 143 current_.cumulative_incremental_marking_duration - | 151 current_.cumulative_incremental_marking_duration - |
| 144 previous_mark_compactor_event_.cumulative_incremental_marking_duration; | 152 previous_mark_compactor_event_.cumulative_incremental_marking_duration; |
| 153 current_.pure_incremental_marking_duration = |
| 154 current_.cumulative_pure_incremental_marking_duration - |
| 155 previous_mark_compactor_event_ |
| 156 .cumulative_pure_incremental_marking_duration; |
| 145 longest_incremental_marking_step_ = 0.0; | 157 longest_incremental_marking_step_ = 0.0; |
| 146 mark_compactor_events_.push_front(current_); | 158 mark_compactor_events_.push_front(current_); |
| 147 } | 159 } |
| 148 | 160 |
| 149 // TODO(ernstm): move the code below out of GCTracer. | 161 // TODO(ernstm): move the code below out of GCTracer. |
| 150 | 162 |
| 151 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; | 163 if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; |
| 152 | 164 |
| 153 double duration = current_.end_time - current_.start_time; | 165 double duration = current_.end_time - current_.start_time; |
| 154 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0); | 166 double spent_in_mutator = Max(current_.start_time - previous_.end_time, 0.0); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 170 } | 182 } |
| 171 | 183 |
| 172 | 184 |
| 173 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) { | 185 void GCTracer::AddIncrementalMarkingStep(double duration, intptr_t bytes) { |
| 174 cumulative_incremental_marking_steps_++; | 186 cumulative_incremental_marking_steps_++; |
| 175 cumulative_incremental_marking_bytes_ += bytes; | 187 cumulative_incremental_marking_bytes_ += bytes; |
| 176 cumulative_incremental_marking_duration_ += duration; | 188 cumulative_incremental_marking_duration_ += duration; |
| 177 longest_incremental_marking_step_ = | 189 longest_incremental_marking_step_ = |
| 178 Max(longest_incremental_marking_step_, duration); | 190 Max(longest_incremental_marking_step_, duration); |
| 179 cumulative_marking_duration_ += duration; | 191 cumulative_marking_duration_ += duration; |
| 192 if (bytes > 0) { |
| 193 cumulative_pure_incremental_marking_duration_ += duration; |
| 194 } |
| 180 } | 195 } |
| 181 | 196 |
| 182 | 197 |
| 183 void GCTracer::Print() const { | 198 void GCTracer::Print() const { |
| 184 PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); | 199 PrintPID("%8.0f ms: ", heap_->isolate()->time_millis_since_init()); |
| 185 | 200 |
| 186 PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", current_.TypeName(false), | 201 PrintF("%s %.1f (%.1f) -> %.1f (%.1f) MB, ", current_.TypeName(false), |
| 187 static_cast<double>(current_.start_object_size) / MB, | 202 static_cast<double>(current_.start_object_size) / MB, |
| 188 static_cast<double>(current_.start_memory_size) / MB, | 203 static_cast<double>(current_.start_memory_size) / MB, |
| 189 static_cast<double>(current_.end_object_size) / MB, | 204 static_cast<double>(current_.end_object_size) / MB, |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 375 } |
| 361 | 376 |
| 362 | 377 |
| 363 intptr_t GCTracer::IncrementalMarkingSpeedInBytesPerMillisecond() const { | 378 intptr_t GCTracer::IncrementalMarkingSpeedInBytesPerMillisecond() const { |
| 364 if (cumulative_incremental_marking_duration_ == 0.0) return 0; | 379 if (cumulative_incremental_marking_duration_ == 0.0) return 0; |
| 365 | 380 |
| 366 // We haven't completed an entire round of incremental marking, yet. | 381 // We haven't completed an entire round of incremental marking, yet. |
| 367 // Use data from GCTracer instead of data from event buffers. | 382 // Use data from GCTracer instead of data from event buffers. |
| 368 if (mark_compactor_events_.empty()) { | 383 if (mark_compactor_events_.empty()) { |
| 369 return static_cast<intptr_t>(cumulative_incremental_marking_bytes_ / | 384 return static_cast<intptr_t>(cumulative_incremental_marking_bytes_ / |
| 370 cumulative_incremental_marking_duration_); | 385 cumulative_pure_incremental_marking_duration_); |
| 371 } | 386 } |
| 372 | 387 |
| 373 intptr_t bytes = 0; | 388 intptr_t bytes = 0; |
| 374 double durations = 0.0; | 389 double durations = 0.0; |
| 375 EventBuffer::const_iterator iter = mark_compactor_events_.begin(); | 390 EventBuffer::const_iterator iter = mark_compactor_events_.begin(); |
| 376 while (iter != mark_compactor_events_.end()) { | 391 while (iter != mark_compactor_events_.end()) { |
| 377 bytes += iter->incremental_marking_bytes; | 392 bytes += iter->incremental_marking_bytes; |
| 378 durations += iter->incremental_marking_duration; | 393 durations += iter->pure_incremental_marking_duration; |
| 379 ++iter; | 394 ++iter; |
| 380 } | 395 } |
| 381 | 396 |
| 382 if (durations == 0.0) return 0; | 397 if (durations == 0.0) return 0; |
| 383 | 398 |
| 384 return static_cast<intptr_t>(bytes / durations); | 399 return static_cast<intptr_t>(bytes / durations); |
| 385 } | 400 } |
| 386 } | 401 } |
| 387 } // namespace v8::internal | 402 } // namespace v8::internal |
| OLD | NEW |