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

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: Implement buckets Created 3 years, 11 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 371
371 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( 372 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf(
372 "gpu/command_buffer_memory/buffer_%d", ring_buffer_id_)); 373 "gpu/command_buffer_memory/buffer_%d", ring_buffer_id_));
373 dump->AddScalar(MemoryAllocatorDump::kNameSize, 374 dump->AddScalar(MemoryAllocatorDump::kNameSize,
374 MemoryAllocatorDump::kUnitsBytes, ring_buffer_size_); 375 MemoryAllocatorDump::kUnitsBytes, ring_buffer_size_);
375 376
376 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) { 377 if (args.level_of_detail != MemoryDumpLevelOfDetail::BACKGROUND) {
377 dump->AddScalar( 378 dump->AddScalar(
378 "free_size", MemoryAllocatorDump::kUnitsBytes, 379 "free_size", MemoryAllocatorDump::kUnitsBytes,
379 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry)); 380 GetTotalFreeEntriesNoWaiting() * sizeof(CommandBufferEntry));
380 auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_); 381 auto shared_memory = ring_buffer_->backing()->shared_memory();
381 const int kImportance = 2; 382 if (shared_memory) {
382 pmd->CreateSharedGlobalAllocatorDump(guid); 383 auto guid = GetBufferGUIDForTracing(tracing_process_id, ring_buffer_id_);
383 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 384 const int kImportance = 2;
385 pmd->CreateSharedGlobalAllocatorDump(guid);
386 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
387 base::SharedMemoryTracker::AddOwnershipEdgeToSharedGlobalDump(pmd, guid,
388 shared_memory->handle(), shared_memory->mapped_size());
389 }
384 } 390 }
385 391
386 return true; 392 return true;
387 } 393 }
388 394
389 } // namespace gpu 395 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698