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

Side by Side Diff: cc/raster/staging_buffer_pool.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (rebase) Created 3 years, 7 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 | « base/memory/shared_memory_tracker.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/raster/staging_buffer_pool.h" 5 #include "cc/raster/staging_buffer_pool.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/memory_coordinator_client_registry.h" 9 #include "base/memory/memory_coordinator_client_registry.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/memory/shared_memory_tracker.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
13 #include "base/trace_event/memory_dump_manager.h" 14 #include "base/trace_event/memory_dump_manager.h"
14 #include "cc/base/container_util.h" 15 #include "cc/base/container_util.h"
15 #include "cc/debug/traced_value.h" 16 #include "cc/debug/traced_value.h"
16 #include "cc/resources/scoped_resource.h" 17 #include "cc/resources/scoped_resource.h"
17 #include "gpu/command_buffer/client/gles2_interface.h" 18 #include "gpu/command_buffer/client/gles2_interface.h"
18 #include "ui/gfx/gpu_memory_buffer_tracing.h"
19 19
20 using base::trace_event::MemoryAllocatorDump; 20 using base::trace_event::MemoryAllocatorDump;
21 using base::trace_event::MemoryAllocatorDumpGuid; 21 using base::trace_event::MemoryAllocatorDumpGuid;
22 using base::trace_event::MemoryDumpLevelOfDetail; 22 using base::trace_event::MemoryDumpLevelOfDetail;
23 23
24 namespace cc { 24 namespace cc {
25 namespace { 25 namespace {
26 26
27 // Delay between checking for query result to be available. 27 // Delay between checking for query result to be available.
28 const int kCheckForQueryResultAvailableTickRateMs = 1; 28 const int kCheckForQueryResultAvailableTickRateMs = 1;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 MemoryAllocatorDump* buffer_dump = pmd->CreateAllocatorDump(buffer_dump_name); 103 MemoryAllocatorDump* buffer_dump = pmd->CreateAllocatorDump(buffer_dump_name);
104 104
105 uint64_t buffer_size_in_bytes = 105 uint64_t buffer_size_in_bytes =
106 ResourceUtil::UncheckedSizeInBytes<uint64_t>(size, format); 106 ResourceUtil::UncheckedSizeInBytes<uint64_t>(size, format);
107 buffer_dump->AddScalar(MemoryAllocatorDump::kNameSize, 107 buffer_dump->AddScalar(MemoryAllocatorDump::kNameSize,
108 MemoryAllocatorDump::kUnitsBytes, 108 MemoryAllocatorDump::kUnitsBytes,
109 buffer_size_in_bytes); 109 buffer_size_in_bytes);
110 buffer_dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, 110 buffer_dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes,
111 in_free_list ? buffer_size_in_bytes : 0); 111 in_free_list ? buffer_size_in_bytes : 0);
112 112
113 // Emit an ownership edge towards a global allocator dump node. 113 base::SharedMemory* shared_memory = gpu_memory_buffer->GetSharedMemory();
114 const uint64_t tracing_process_id = 114 if (shared_memory) {
115 base::trace_event::MemoryDumpManager::GetInstance() 115 base::SharedMemoryTracker::AddOwnershipEdges(pmd, buffer_dump->guid(),
116 ->GetTracingProcessId(); 116 *shared_memory);
117 auto shared_buffer_guid = 117 } else {
118 gpu_memory_buffer->GetGUIDForTracing(tracing_process_id); 118 // Emit an ownership edge towards a global allocator dump node.
119 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); 119 const uint64_t tracing_process_id =
120 base::trace_event::MemoryDumpManager::GetInstance()
121 ->GetTracingProcessId();
122 auto shared_buffer_guid =
123 gpu_memory_buffer->GetGUIDForTracing(tracing_process_id);
124 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid);
120 125
121 // By creating an edge with a higher |importance| (w.r.t. browser-side dumps) 126 // By creating an edge with a higher |importance| (w.r.t. browser-side
122 // the tracing UI will account the effective size of the buffer to the child. 127 // dumps) the tracing UI will account the effective size of the buffer to
123 const int kImportance = 2; 128 // the child.
124 pmd->AddOwnershipEdge(buffer_dump->guid(), shared_buffer_guid, kImportance); 129 const int kImportance = 2;
130 pmd->AddOwnershipEdge(buffer_dump->guid(), shared_buffer_guid, kImportance);
131 }
125 } 132 }
126 133
127 StagingBufferPool::StagingBufferPool(base::SequencedTaskRunner* task_runner, 134 StagingBufferPool::StagingBufferPool(base::SequencedTaskRunner* task_runner,
128 ContextProvider* worker_context_provider, 135 ContextProvider* worker_context_provider,
129 ResourceProvider* resource_provider, 136 ResourceProvider* resource_provider,
130 bool use_partial_raster, 137 bool use_partial_raster,
131 int max_staging_buffer_usage_in_bytes) 138 int max_staging_buffer_usage_in_bytes)
132 : task_runner_(task_runner), 139 : task_runner_(task_runner),
133 worker_context_provider_(worker_context_provider), 140 worker_context_provider_(worker_context_provider),
134 resource_provider_(resource_provider), 141 resource_provider_(resource_provider),
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 440 }
434 } 441 }
435 442
436 void StagingBufferPool::OnPurgeMemory() { 443 void StagingBufferPool::OnPurgeMemory() {
437 base::AutoLock lock(lock_); 444 base::AutoLock lock(lock_);
438 // Release all buffers, regardless of how recently they were used. 445 // Release all buffers, regardless of how recently they were used.
439 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); 446 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
440 } 447 }
441 448
442 } // namespace cc 449 } // namespace cc
OLDNEW
« no previous file with comments | « base/memory/shared_memory_tracker.cc ('k') | cc/resources/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698