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

Unified Diff: third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp

Issue 2890363003: Enable sharding of AllocationRegister on desktop. (Closed)
Patch Set: comments from primiano, thakis. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
diff --git a/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp b/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
index baefa38a3657d96e2ca457172b38070de389e552..d4077870cb4a24b2248731ff0b491e088bc20cd0 100644
--- a/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
+++ b/third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp
@@ -7,7 +7,6 @@
#include <unordered_map>
#include "base/trace_event/heap_profiler_allocation_context_tracker.h"
-#include "base/trace_event/heap_profiler_allocation_register.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event_memory_overhead.h"
@@ -66,24 +65,16 @@ bool BlinkGCMemoryDumpProvider::OnMemoryDump(
BlinkGC::kForcedGC);
DumpMemoryTotals(memory_dump);
- if (is_heap_profiling_enabled_) {
+ if (allocation_register_.is_enabled()) {
// Overhead should always be reported, regardless of light vs. heavy.
base::trace_event::TraceEventMemoryOverhead overhead;
std::unordered_map<base::trace_event::AllocationContext,
base::trace_event::AllocationMetrics>
metrics_by_context;
- {
- MutexLocker locker(allocation_register_mutex_);
- if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) {
- for (const auto& alloc_size : *allocation_register_) {
- base::trace_event::AllocationMetrics& metrics =
- metrics_by_context[alloc_size.context];
- metrics.size += alloc_size.size;
- metrics.count++;
- }
- }
- allocation_register_->EstimateTraceMemoryOverhead(&overhead);
+ if (level_of_detail == MemoryDumpLevelOfDetail::DETAILED) {
+ allocation_register_.UpdateAndReturnsMetrics(metrics_by_context);
}
+ allocation_register_.EstimateTraceMemoryOverhead(&overhead);
memory_dump->DumpHeapUsage(metrics_by_context, overhead, "blink_gc");
}
@@ -95,18 +86,14 @@ bool BlinkGCMemoryDumpProvider::OnMemoryDump(
void BlinkGCMemoryDumpProvider::OnHeapProfilingEnabled(bool enabled) {
if (enabled) {
- {
- MutexLocker locker(allocation_register_mutex_);
- if (!allocation_register_)
- allocation_register_.reset(new base::trace_event::AllocationRegister());
- }
+ allocation_register_.SetEnabled();
HeapAllocHooks::SetAllocationHook(ReportAllocation);
HeapAllocHooks::SetFreeHook(ReportFree);
} else {
HeapAllocHooks::SetAllocationHook(nullptr);
HeapAllocHooks::SetFreeHook(nullptr);
+ allocation_register_.SetDisabled();
}
- is_heap_profiling_enabled_ = enabled;
}
base::trace_event::MemoryAllocatorDump*
@@ -124,8 +111,7 @@ void BlinkGCMemoryDumpProvider::ClearProcessDumpForCurrentGC() {
BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider()
: current_process_memory_dump_(new base::trace_event::ProcessMemoryDump(
nullptr,
- {base::trace_event::MemoryDumpLevelOfDetail::DETAILED})),
- is_heap_profiling_enabled_(false) {}
+ {base::trace_event::MemoryDumpLevelOfDetail::DETAILED})) {}
void BlinkGCMemoryDumpProvider::insert(Address address,
size_t size,
@@ -136,15 +122,15 @@ void BlinkGCMemoryDumpProvider::insert(Address address,
->GetContextSnapshot(&context))
return;
context.type_name = type_name;
- MutexLocker locker(allocation_register_mutex_);
- if (allocation_register_)
- allocation_register_->Insert(address, size, context);
+ if (!allocation_register_.is_enabled())
+ return;
+ allocation_register_.Insert(address, size, context);
}
void BlinkGCMemoryDumpProvider::Remove(Address address) {
- MutexLocker locker(allocation_register_mutex_);
- if (allocation_register_)
- allocation_register_->Remove(address);
+ if (!allocation_register_.is_enabled())
+ return;
+ allocation_register_.Remove(address);
}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698