Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/allocator/features.h" | 10 #include "base/allocator/features.h" |
| (...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 726 uint64_t sum = 0; | 726 uint64_t sum = 0; |
| 727 for (const auto& kv : pmd->allocator_dumps()) { | 727 for (const auto& kv : pmd->allocator_dumps()) { |
| 728 auto name = StringPiece(kv.first); | 728 auto name = StringPiece(kv.first); |
| 729 if (MatchPattern(name, pattern)) | 729 if (MatchPattern(name, pattern)) |
| 730 sum += kv.second->GetSize(); | 730 sum += kv.second->GetSize(); |
| 731 } | 731 } |
| 732 return sum / 1024; | 732 return sum / 1024; |
| 733 } | 733 } |
| 734 | 734 |
| 735 // static | 735 // static |
| 736 void MemoryDumpManager::FillOsDumpFromProcessMemoryDump( | |
|
Primiano Tucci (use gerrit)
2017/03/24 11:44:43
move this to the anonymous namespace (and remove t
hjd
2017/03/24 12:12:54
Done.
| |
| 737 MemoryDumpCallbackResult::OSMemDump& osDump, | |
| 738 ProcessMemoryDump* pmd) { | |
| 739 if (pmd->has_process_totals()) { | |
| 740 auto* totals = pmd->process_totals(); | |
| 741 osDump.resident_set_kb = totals->resident_set_bytes() / 1024; | |
| 742 } | |
| 743 } | |
| 744 | |
| 745 // static | |
| 736 void MemoryDumpManager::FinalizeDumpAndAddToTrace( | 746 void MemoryDumpManager::FinalizeDumpAndAddToTrace( |
| 737 std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) { | 747 std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state) { |
| 738 HEAP_PROFILER_SCOPED_IGNORE; | 748 HEAP_PROFILER_SCOPED_IGNORE; |
| 739 DCHECK(pmd_async_state->pending_dump_providers.empty()); | 749 DCHECK(pmd_async_state->pending_dump_providers.empty()); |
| 740 const uint64_t dump_guid = pmd_async_state->req_args.dump_guid; | 750 const uint64_t dump_guid = pmd_async_state->req_args.dump_guid; |
| 741 if (!pmd_async_state->callback_task_runner->BelongsToCurrentThread()) { | 751 if (!pmd_async_state->callback_task_runner->BelongsToCurrentThread()) { |
| 742 scoped_refptr<SingleThreadTaskRunner> callback_task_runner = | 752 scoped_refptr<SingleThreadTaskRunner> callback_task_runner = |
| 743 pmd_async_state->callback_task_runner; | 753 pmd_async_state->callback_task_runner; |
| 744 callback_task_runner->PostTask( | 754 callback_task_runner->PostTask( |
| 745 FROM_HERE, Bind(&MemoryDumpManager::FinalizeDumpAndAddToTrace, | 755 FROM_HERE, Bind(&MemoryDumpManager::FinalizeDumpAndAddToTrace, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 784 GetDumpsSumKb("v8/*", process_memory_dump); | 794 GetDumpsSumKb("v8/*", process_memory_dump); |
| 785 | 795 |
| 786 // partition_alloc reports sizes for both allocated_objects and | 796 // partition_alloc reports sizes for both allocated_objects and |
| 787 // partitions. The memory allocated_objects uses is a subset of | 797 // partitions. The memory allocated_objects uses is a subset of |
| 788 // the partitions memory so to avoid double counting we only | 798 // the partitions memory so to avoid double counting we only |
| 789 // count partitions memory. | 799 // count partitions memory. |
| 790 result.chrome_dump.partition_alloc_total_kb = | 800 result.chrome_dump.partition_alloc_total_kb = |
| 791 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump); | 801 GetDumpsSumKb("partition_alloc/partitions/*", process_memory_dump); |
| 792 result.chrome_dump.blink_gc_total_kb = | 802 result.chrome_dump.blink_gc_total_kb = |
| 793 GetDumpsSumKb("blink_gc", process_memory_dump); | 803 GetDumpsSumKb("blink_gc", process_memory_dump); |
| 804 } else { | |
| 805 auto& os_dump = result.extra_processes_dump[pid]; | |
| 806 FillOsDumpFromProcessMemoryDump(os_dump, process_memory_dump); | |
|
Primiano Tucci (use gerrit)
2017/03/24 11:44:43
I think we want to do this also in the case above
hjd
2017/03/24 12:12:54
oops, I must have lost it in a rebase, thanks!
| |
| 794 } | 807 } |
| 795 } | 808 } |
| 796 | 809 |
| 797 bool tracing_still_enabled; | 810 bool tracing_still_enabled; |
| 798 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); | 811 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); |
| 799 if (!tracing_still_enabled) { | 812 if (!tracing_still_enabled) { |
| 800 pmd_async_state->dump_successful = false; | 813 pmd_async_state->dump_successful = false; |
| 801 VLOG(1) << kLogPrefix << " failed because tracing was disabled before" | 814 VLOG(1) << kLogPrefix << " failed because tracing was disabled before" |
| 802 << " the dump was completed"; | 815 << " the dump was completed"; |
| 803 } | 816 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 if (iter == process_dumps.end()) { | 1009 if (iter == process_dumps.end()) { |
| 997 std::unique_ptr<ProcessMemoryDump> new_pmd( | 1010 std::unique_ptr<ProcessMemoryDump> new_pmd( |
| 998 new ProcessMemoryDump(session_state, dump_args)); | 1011 new ProcessMemoryDump(session_state, dump_args)); |
| 999 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; | 1012 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; |
| 1000 } | 1013 } |
| 1001 return iter->second.get(); | 1014 return iter->second.get(); |
| 1002 } | 1015 } |
| 1003 | 1016 |
| 1004 } // namespace trace_event | 1017 } // namespace trace_event |
| 1005 } // namespace base | 1018 } // namespace base |
| OLD | NEW |