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

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper.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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file contains the implementation of the command buffer helper class. 5 // This file contains the implementation of the command buffer helper class.
6 6
7 #include "gpu/command_buffer/client/cmd_buffer_helper.h" 7 #include "gpu/command_buffer/client/cmd_buffer_helper.h"
8 8
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/shared_memory_tracker.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "base/trace_event/memory_allocator_dump.h" 17 #include "base/trace_event/memory_allocator_dump.h"
17 #include "base/trace_event/memory_dump_manager.h" 18 #include "base/trace_event/memory_dump_manager.h"
18 #include "base/trace_event/process_memory_dump.h" 19 #include "base/trace_event/process_memory_dump.h"
19 #include "base/trace_event/trace_event.h" 20 #include "base/trace_event/trace_event.h"
20 #include "gpu/command_buffer/common/buffer.h" 21 #include "gpu/command_buffer/common/buffer.h"
21 #include "gpu/command_buffer/common/command_buffer.h" 22 #include "gpu/command_buffer/common/command_buffer.h"
22 #include "gpu/command_buffer/common/constants.h" 23 #include "gpu/command_buffer/common/constants.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 369
369 bool CommandBufferHelper::OnMemoryDump( 370 bool CommandBufferHelper::OnMemoryDump(
370 const base::trace_event::MemoryDumpArgs& args, 371 const base::trace_event::MemoryDumpArgs& args,
371 base::trace_event::ProcessMemoryDump* pmd) { 372 base::trace_event::ProcessMemoryDump* pmd) {
372 using base::trace_event::MemoryAllocatorDump; 373 using base::trace_event::MemoryAllocatorDump;
373 using base::trace_event::MemoryDumpLevelOfDetail; 374 using base::trace_event::MemoryDumpLevelOfDetail;
374 375
375 if (!HaveRingBuffer()) 376 if (!HaveRingBuffer())
376 return true; 377 return true;
377 378
378 const uint64_t tracing_process_id =
379 base::trace_event::MemoryDumpManager::GetInstance()
380 ->GetTracingProcessId();
381
382 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( 379 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf(
383 "gpu/command_buffer_memory/buffer_%d", ring_buffer_id_)); 380 "gpu/command_buffer_memory/buffer_%d", ring_buffer_id_));
384 dump->AddScalar(MemoryAllocatorDump::kNameSize, 381 dump->AddScalar(MemoryAllocatorDump::kNameSize,
385 MemoryAllocatorDump::kUnitsBytes, ring_buffer_size_); 382 MemoryAllocatorDump::kUnitsBytes, ring_buffer_size_);
386 383
387 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) { 384 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) {
388 dump->AddScalar( 385 dump->AddScalar(
389 "free_size", MemoryAllocatorDump::kUnitsBytes, 386 "free_size", MemoryAllocatorDump::kUnitsBytes,
390 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry)); 387 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry));
391 auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_); 388 auto* shared_memory = ring_buffer_->backing()->shared_memory();
392 const int kImportance = 2; 389 if (shared_memory) {
393 pmd->CreateSharedGlobalAllocatorDump(guid); 390 base::SharedMemoryTracker::AddOwnershipEdges(pmd, dump->guid(),
394 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 391 *shared_memory);
392 } else {
393 const uint64_t tracing_process_id =
394 base::trace_event::MemoryDumpManager::GetInstance()
395 ->GetTracingProcessId();
396 auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_);
397 const int kImportance = 2;
398 pmd->CreateSharedGlobalAllocatorDump(guid);
399 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
400 }
395 } 401 }
396 402
397 return true; 403 return true;
398 } 404 }
399 405
400 } // namespace gpu 406 } // namespace gpu
OLDNEW
« no previous file with comments | « content/browser/gpu/browser_gpu_memory_buffer_manager.cc ('k') | gpu/command_buffer/client/gles2_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698