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

Side by Side Diff: src/heap/gc-tracer.cc

Issue 2313193002: [Tracing] Fix runtime call stats tracing for GC. (Closed)
Patch Set: Created 4 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 unified diff | Download patch
« src/counters.h ('K') | « src/counters-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/heap/gc-tracer.h" 5 #include "src/heap/gc-tracer.h"
6 6
7 #include "src/counters.h" 7 #include "src/counters.h"
8 #include "src/heap/heap-inl.h" 8 #include "src/heap/heap-inl.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 static intptr_t CountTotalHolesSize(Heap* heap) { 14 static intptr_t CountTotalHolesSize(Heap* heap) {
15 intptr_t holes_size = 0; 15 intptr_t holes_size = 0;
16 OldSpaces spaces(heap); 16 OldSpaces spaces(heap);
17 for (OldSpace* space = spaces.next(); space != NULL; space = spaces.next()) { 17 for (OldSpace* space = spaces.next(); space != NULL; space = spaces.next()) {
18 holes_size += space->Waste() + space->Available(); 18 holes_size += space->Waste() + space->Available();
19 } 19 }
20 return holes_size; 20 return holes_size;
21 } 21 }
22 22
23 23
24 GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope) 24 GCTracer::Scope::Scope(GCTracer* tracer, ScopeId scope)
25 : tracer_(tracer), scope_(scope) { 25 : tracer_(tracer), scope_(scope) {
26 start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs(); 26 start_time_ = tracer_->heap_->MonotonicallyIncreasingTimeInMs();
27 // TODO(cbruni): remove once we fully moved to a trace-based system. 27 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED()) {
28 if (FLAG_runtime_call_stats) { 28 RuntimeCallStats::Enter(
29 tracer_->heap_->isolate()->counters()->tracing_runtime_call_stats(),
30 &timer_, &RuntimeCallStats::GC);
31 } else if (FLAG_runtime_call_stats) {
32 // TODO(cbruni): remove once we fully moved to a trace-based system.
29 RuntimeCallStats::Enter( 33 RuntimeCallStats::Enter(
30 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_, 34 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_,
31 &RuntimeCallStats::GC); 35 &RuntimeCallStats::GC);
32 } 36 }
33 // TODO(lpy): Add a tracing equivalent for the runtime call stats.
34 } 37 }
35 38
36 GCTracer::Scope::~Scope() { 39 GCTracer::Scope::~Scope() {
37 tracer_->AddScopeSample( 40 tracer_->AddScopeSample(
38 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_); 41 scope_, tracer_->heap_->MonotonicallyIncreasingTimeInMs() - start_time_);
39 // TODO(cbruni): remove once we fully moved to a trace-based system. 42 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED()) {
40 if (FLAG_runtime_call_stats) { 43 RuntimeCallStats::Leave(
44 tracer_->heap_->isolate()->counters()->tracing_runtime_call_stats(),
45 &timer_);
46 } else if (FLAG_runtime_call_stats) {
47 // TODO(cbruni): remove once we fully moved to a trace-based system.
41 RuntimeCallStats::Leave( 48 RuntimeCallStats::Leave(
42 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_); 49 tracer_->heap_->isolate()->counters()->runtime_call_stats(), &timer_);
43 } 50 }
44 // TODO(lpy): Add a tracing equivalent for the runtime call stats.
45 } 51 }
46 52
47 const char* GCTracer::Scope::Name(ScopeId id) { 53 const char* GCTracer::Scope::Name(ScopeId id) {
48 #define CASE(scope) \ 54 #define CASE(scope) \
49 case Scope::scope: \ 55 case Scope::scope: \
50 return "V8.GC_" #scope; 56 return "V8.GC_" #scope;
51 switch (id) { 57 switch (id) {
52 TRACER_SCOPES(CASE) 58 TRACER_SCOPES(CASE)
53 case Scope::NUMBER_OF_SCOPES: 59 case Scope::NUMBER_OF_SCOPES:
54 break; 60 break;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) { 207 for (int i = 0; i < Scope::NUMBER_OF_SCOPES; i++) {
202 current_.scopes[i] = 0; 208 current_.scopes[i] = 0;
203 } 209 }
204 210
205 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB); 211 int committed_memory = static_cast<int>(heap_->CommittedMemory() / KB);
206 int used_memory = static_cast<int>(current_.start_object_size / KB); 212 int used_memory = static_cast<int>(current_.start_object_size / KB);
207 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample( 213 heap_->isolate()->counters()->aggregated_memory_heap_committed()->AddSample(
208 start_time, committed_memory); 214 start_time, committed_memory);
209 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample( 215 heap_->isolate()->counters()->aggregated_memory_heap_used()->AddSample(
210 start_time, used_memory); 216 start_time, used_memory);
211 // TODO(cbruni): remove once we fully moved to a trace-based system. 217 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED()) {
212 if (FLAG_runtime_call_stats) { 218 RuntimeCallStats::Enter(
219 heap_->isolate()->counters()->tracing_runtime_call_stats(), &timer_,
220 &RuntimeCallStats::GC);
221 } else if (FLAG_runtime_call_stats) {
222 // TODO(cbruni): remove once we fully moved to a trace-based system.
213 RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(), 223 RuntimeCallStats::Enter(heap_->isolate()->counters()->runtime_call_stats(),
214 &timer_, &RuntimeCallStats::GC); 224 &timer_, &RuntimeCallStats::GC);
215 } 225 }
216 // TODO(lpy): Add a tracing equivalent for the runtime call stats.
217 } 226 }
218 227
219 void GCTracer::MergeBaseline(const Event& baseline) { 228 void GCTracer::MergeBaseline(const Event& baseline) {
220 current_.incremental_marking_bytes = 229 current_.incremental_marking_bytes =
221 current_.cumulative_incremental_marking_bytes - 230 current_.cumulative_incremental_marking_bytes -
222 baseline.cumulative_incremental_marking_bytes; 231 baseline.cumulative_incremental_marking_bytes;
223 current_.pure_incremental_marking_duration = 232 current_.pure_incremental_marking_duration =
224 current_.cumulative_pure_incremental_marking_duration - 233 current_.cumulative_pure_incremental_marking_duration -
225 baseline.cumulative_pure_incremental_marking_duration; 234 baseline.cumulative_pure_incremental_marking_duration;
226 for (int i = Scope::FIRST_INCREMENTAL_SCOPE; 235 for (int i = Scope::FIRST_INCREMENTAL_SCOPE;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 if (FLAG_trace_gc_nvp) { 316 if (FLAG_trace_gc_nvp) {
308 PrintNVP(); 317 PrintNVP();
309 } else { 318 } else {
310 Print(); 319 Print();
311 } 320 }
312 321
313 if (FLAG_trace_gc) { 322 if (FLAG_trace_gc) {
314 heap_->PrintShortHeapStatistics(); 323 heap_->PrintShortHeapStatistics();
315 } 324 }
316 325
317 // TODO(cbruni): remove once we fully moved to a trace-based system. 326 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED()) {
318 if (FLAG_runtime_call_stats) { 327 RuntimeCallStats::Leave(
328 heap_->isolate()->counters()->tracing_runtime_call_stats(), &timer_);
329 } else if (FLAG_runtime_call_stats) {
330 // TODO(cbruni): remove once we fully moved to a trace-based system.
319 RuntimeCallStats::Leave(heap_->isolate()->counters()->runtime_call_stats(), 331 RuntimeCallStats::Leave(heap_->isolate()->counters()->runtime_call_stats(),
320 &timer_); 332 &timer_);
321 } 333 }
322 // TODO(lpy): Add a tracing equivalent for the runtime call stats.
323 } 334 }
324 335
325 336
326 void GCTracer::SampleAllocation(double current_ms, 337 void GCTracer::SampleAllocation(double current_ms,
327 size_t new_space_counter_bytes, 338 size_t new_space_counter_bytes,
328 size_t old_generation_counter_bytes) { 339 size_t old_generation_counter_bytes) {
329 if (allocation_time_ms_ == 0) { 340 if (allocation_time_ms_ == 0) {
330 // It is the first sample. 341 // It is the first sample.
331 allocation_time_ms_ = current_ms; 342 allocation_time_ms_ = current_ms;
332 new_space_allocation_counter_bytes_ = new_space_counter_bytes; 343 new_space_allocation_counter_bytes_ = new_space_counter_bytes;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 } 838 }
828 839
829 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); } 840 void GCTracer::ResetSurvivalEvents() { recorded_survival_ratios_.Reset(); }
830 841
831 void GCTracer::NotifyIncrementalMarkingStart() { 842 void GCTracer::NotifyIncrementalMarkingStart() {
832 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs(); 843 incremental_marking_start_time_ = heap_->MonotonicallyIncreasingTimeInMs();
833 } 844 }
834 845
835 } // namespace internal 846 } // namespace internal
836 } // namespace v8 847 } // namespace v8
OLDNEW
« src/counters.h ('K') | « src/counters-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698