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

Side by Side Diff: gin/v8_isolate_memory_dump_provider.cc

Issue 1266003003: [tracing] Add light dumps in the V8 dump provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@light_dumps
Patch Set: Rebase. Created 5 years, 4 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
« no previous file with comments | « gin/v8_isolate_memory_dump_provider.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium 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 "gin/v8_isolate_memory_dump_provider.h" 5 #include "gin/v8_isolate_memory_dump_provider.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "base/trace_event/memory_dump_manager.h" 9 #include "base/trace_event/memory_dump_manager.h"
10 #include "base/trace_event/process_memory_dump.h" 10 #include "base/trace_event/process_memory_dump.h"
(...skipping 17 matching lines...) Expand all
28 // Called at trace dump point time. Creates a snapshot with the memory counters 28 // Called at trace dump point time. Creates a snapshot with the memory counters
29 // for the current isolate. 29 // for the current isolate.
30 bool V8IsolateMemoryDumpProvider::OnMemoryDump( 30 bool V8IsolateMemoryDumpProvider::OnMemoryDump(
31 const base::trace_event::MemoryDumpArgs& args, 31 const base::trace_event::MemoryDumpArgs& args,
32 base::trace_event::ProcessMemoryDump* process_memory_dump) { 32 base::trace_event::ProcessMemoryDump* process_memory_dump) {
33 // TODO(ssid): Use MemoryDumpArgs to create light dumps when requested 33 // TODO(ssid): Use MemoryDumpArgs to create light dumps when requested
34 // (crbug.com/499731). 34 // (crbug.com/499731).
35 35
36 if (isolate_holder_->access_mode() == IsolateHolder::kUseLocker) { 36 if (isolate_holder_->access_mode() == IsolateHolder::kUseLocker) {
37 v8::Locker locked(isolate_holder_->isolate()); 37 v8::Locker locked(isolate_holder_->isolate());
38 DumpHeapStatistics(process_memory_dump); 38 DumpHeapStatistics(args, process_memory_dump);
39 } else { 39 } else {
40 DumpHeapStatistics(process_memory_dump); 40 DumpHeapStatistics(args, process_memory_dump);
41 } 41 }
42 return true; 42 return true;
43 } 43 }
44 44
45 void V8IsolateMemoryDumpProvider::DumpHeapStatistics( 45 void V8IsolateMemoryDumpProvider::DumpHeapStatistics(
46 const base::trace_event::MemoryDumpArgs& args,
46 base::trace_event::ProcessMemoryDump* process_memory_dump) { 47 base::trace_event::ProcessMemoryDump* process_memory_dump) {
47 std::string dump_base_name = 48 std::string dump_base_name =
48 base::StringPrintf("v8/isolate_%p", isolate_holder_->isolate()); 49 base::StringPrintf("v8/isolate_%p", isolate_holder_->isolate());
49 50
50 // Dump statistics of the heap's spaces. 51 // Dump statistics of the heap's spaces.
51 std::string space_name_prefix = dump_base_name + "/heap_spaces"; 52 std::string space_name_prefix = dump_base_name + "/heap_spaces";
52 v8::HeapStatistics heap_statistics; 53 v8::HeapStatistics heap_statistics;
53 isolate_holder_->isolate()->GetHeapStatistics(&heap_statistics); 54 isolate_holder_->isolate()->GetHeapStatistics(&heap_statistics);
54 55
55 size_t known_spaces_used_size = 0; 56 size_t known_spaces_used_size = 0;
(...skipping 30 matching lines...) Expand all
86 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 87 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
87 heap_statistics.total_heap_size() - known_spaces_size); 88 heap_statistics.total_heap_size() - known_spaces_size);
88 89
89 auto other_allocated_dump = process_memory_dump->CreateAllocatorDump( 90 auto other_allocated_dump = process_memory_dump->CreateAllocatorDump(
90 other_spaces_name + "/allocated_objects"); 91 other_spaces_name + "/allocated_objects");
91 other_allocated_dump->AddScalar( 92 other_allocated_dump->AddScalar(
92 base::trace_event::MemoryAllocatorDump::kNameSize, 93 base::trace_event::MemoryAllocatorDump::kNameSize,
93 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 94 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
94 heap_statistics.used_heap_size() - known_spaces_used_size); 95 heap_statistics.used_heap_size() - known_spaces_used_size);
95 96
97 // If light dump is requested, then object statistics are not dumped
98 if (args.level_of_detail ==
99 base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW)
100 return;
101
96 // Dump statistics of the heap's live objects from last GC. 102 // Dump statistics of the heap's live objects from last GC.
97 std::string object_name_prefix = dump_base_name + "/heap_objects"; 103 std::string object_name_prefix = dump_base_name + "/heap_objects";
98 bool did_dump_object_stats = false; 104 bool did_dump_object_stats = false;
99 const size_t object_types = 105 const size_t object_types =
100 isolate_holder_->isolate()->NumberOfTrackedHeapObjectTypes(); 106 isolate_holder_->isolate()->NumberOfTrackedHeapObjectTypes();
101 for (size_t type_index = 0; type_index < object_types; type_index++) { 107 for (size_t type_index = 0; type_index < object_types; type_index++) {
102 v8::HeapObjectStatistics object_statistics; 108 v8::HeapObjectStatistics object_statistics;
103 if (!isolate_holder_->isolate()->GetHeapObjectStatisticsAtLastGC( 109 if (!isolate_holder_->isolate()->GetHeapObjectStatisticsAtLastGC(
104 &object_statistics, type_index)) 110 &object_statistics, type_index))
105 continue; 111 continue;
(...skipping 25 matching lines...) Expand all
131 } 137 }
132 138
133 if (did_dump_object_stats) { 139 if (did_dump_object_stats) {
134 process_memory_dump->AddOwnershipEdge( 140 process_memory_dump->AddOwnershipEdge(
135 process_memory_dump->CreateAllocatorDump(object_name_prefix)->guid(), 141 process_memory_dump->CreateAllocatorDump(object_name_prefix)->guid(),
136 process_memory_dump->CreateAllocatorDump(space_name_prefix)->guid()); 142 process_memory_dump->CreateAllocatorDump(space_name_prefix)->guid());
137 } 143 }
138 } 144 }
139 145
140 } // namespace gin 146 } // namespace gin
OLDNEW
« no previous file with comments | « gin/v8_isolate_memory_dump_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698