Commit 25ed8415 authored by Siddhartha's avatar Siddhartha Committed by Commit Bot

MemoryInfra: Fix AutoComplete provider and enable on background mode

There could be multiple providers. So, each must create allocator dumps
with distinct names. Refer notes on GetOrCreateAllocatorDump.
Group autocomplete and in_memory_url_index dumps under different child
dumps for easier collection of metrics.

BUG=803822
TBR=mpearson@chromium.org

Change-Id: I872491bb1496572600fc6b6f87d9198a76eea8c7
Reviewed-on: https://chromium-review.googlesource.com/961263
Commit-Queue: Siddhartha S <ssid@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543017}
parent 46a5c11a
...@@ -20,6 +20,7 @@ namespace { ...@@ -20,6 +20,7 @@ namespace {
// little processor and memory overhead. // little processor and memory overhead.
const char* const kDumpProviderWhitelist[] = { const char* const kDumpProviderWhitelist[] = {
"android::ResourceManagerImpl", "android::ResourceManagerImpl",
"AutocompleteController",
"BlinkGC", "BlinkGC",
"BlinkObjectCounters", "BlinkObjectCounters",
"ClientDiscardableSharedMemoryManager", "ClientDiscardableSharedMemoryManager",
...@@ -202,7 +203,8 @@ const char* const kAllocatorDumpNameWhitelist[] = { ...@@ -202,7 +203,8 @@ const char* const kAllocatorDumpNameWhitelist[] = {
"net/url_request_context/unknown/0x?/http_cache/memory_backend", "net/url_request_context/unknown/0x?/http_cache/memory_backend",
"net/url_request_context/unknown/0x?/http_cache/simple_backend", "net/url_request_context/unknown/0x?/http_cache/simple_backend",
"net/url_request_context/unknown/0x?/http_network_session", "net/url_request_context/unknown/0x?/http_network_session",
"omnibox/in_memory_url_index_0x?", "omnibox/autocomplete_controller/0x?",
"omnibox/in_memory_url_index/0x?",
"web_cache/Image_resources", "web_cache/Image_resources",
"web_cache/CSS stylesheet_resources", "web_cache/CSS stylesheet_resources",
"web_cache/Script_resources", "web_cache/Script_resources",
......
...@@ -355,11 +355,13 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) { ...@@ -355,11 +355,13 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, FocusSearch) {
IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MemoryTracing) { IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MemoryTracing) {
auto* in_memory_url_index = InMemoryURLIndexFactory::GetForProfile(profile()); auto* in_memory_url_index = InMemoryURLIndexFactory::GetForProfile(profile());
auto* autocomplete_controller = GetAutocompleteController();
const std::vector<std::string> expected_names{ const std::vector<std::string> expected_names{
base::StringPrintf("omnibox/in_memory_url_index_0x%" PRIXPTR, base::StringPrintf("omnibox/in_memory_url_index/0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(in_memory_url_index)), reinterpret_cast<uintptr_t>(in_memory_url_index)),
"omnibox/autocomplete_controller"}; base::StringPrintf("omnibox/autocomplete_controller/0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(autocomplete_controller))};
auto OnMemoryDumpDone = auto OnMemoryDumpDone =
[](const std::vector<std::string>& expected_names, base::OnceClosure quit, [](const std::vector<std::string>& expected_names, base::OnceClosure quit,
...@@ -377,7 +379,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MemoryTracing) { ...@@ -377,7 +379,7 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MemoryTracing) {
base::RunLoop run_loop; base::RunLoop run_loop;
base::trace_event::MemoryDumpRequestArgs args{ base::trace_event::MemoryDumpRequestArgs args{
1 /* dump_guid*/, base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED, 1 /* dump_guid*/, base::trace_event::MemoryDumpType::EXPLICITLY_TRIGGERED,
base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND};
base::trace_event::MemoryDumpManager::GetInstance()->CreateProcessDump( base::trace_event::MemoryDumpManager::GetInstance()->CreateProcessDump(
args, base::BindRepeating(OnMemoryDumpDone, expected_names, args, base::BindRepeating(OnMemoryDumpDone, expected_names,
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#include "components/omnibox/browser/autocomplete_controller.h" #include "components/omnibox/browser/autocomplete_controller.h"
#include <inttypes.h>
#include <cstddef> #include <cstddef>
#include <memory> #include <memory>
#include <numeric> #include <numeric>
...@@ -760,8 +762,9 @@ bool AutocompleteController::OnMemoryDump( ...@@ -760,8 +762,9 @@ bool AutocompleteController::OnMemoryDump(
res += input_.EstimateMemoryUsage(); res += input_.EstimateMemoryUsage();
res += result_.EstimateMemoryUsage(); res += result_.EstimateMemoryUsage();
auto* dump = process_memory_dump->GetOrCreateAllocatorDump( auto* dump = process_memory_dump->CreateAllocatorDump(
"omnibox/autocomplete_controller"); base::StringPrintf("omnibox/autocomplete_controller/0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(this)));
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes, res); base::trace_event::MemoryAllocatorDump::kUnitsBytes, res);
return true; return true;
......
...@@ -225,7 +225,7 @@ bool InMemoryURLIndex::OnMemoryDump( ...@@ -225,7 +225,7 @@ bool InMemoryURLIndex::OnMemoryDump(
res += sizeof(URLIndexPrivateData) + private_data_->EstimateMemoryUsage(); res += sizeof(URLIndexPrivateData) + private_data_->EstimateMemoryUsage();
const std::string dump_name = const std::string dump_name =
base::StringPrintf("omnibox/in_memory_url_index_0x%" PRIXPTR, base::StringPrintf("omnibox/in_memory_url_index/0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(this)); reinterpret_cast<uintptr_t>(this));
auto* dump = process_memory_dump->CreateAllocatorDump(dump_name); auto* dump = process_memory_dump->CreateAllocatorDump(dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment