Commit e1b21dc7 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Add memory metric to trace event to investigate omnibox performance

Adding estimated memory usage to the quick history provider.
it is suspected to be slow and cause jank on UI thread when memory usage
is high.

These metrics will be received with slow-reports and will help to
investigate some jank on UI thread.

R=mpearson@chromium.org

Bug: 868419
Change-Id: I344f84ec00f318fdb9db63c5b464b119a9d5e3eb
Reviewed-on: https://chromium-review.googlesource.com/1156847
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579919}
parent a0536c3a
......@@ -45,7 +45,13 @@ HistoryQuickProvider::HistoryQuickProvider(AutocompleteProviderClient* client)
void HistoryQuickProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
TRACE_EVENT0("omnibox", "HistoryQuickProvider::Start");
// TODO(etienneb): Remove metrics when https://crbug/868419 is closed.
size_t memory_usage = 0;
if (in_memory_url_index_)
memory_usage = in_memory_url_index_->EstimateMemoryUsage();
TRACE_EVENT2("omnibox", "HistoryQuickProvider::Start",
"memory_url_index_.memory_usage", memory_usage, "text_length",
input.text().length());
matches_.clear();
if (disabled_ || input.from_omnibox_focus())
return;
......
......@@ -123,6 +123,18 @@ void InMemoryURLIndex::Init() {
PostRestoreFromCacheFileTask();
}
size_t InMemoryURLIndex::EstimateMemoryUsage() const {
size_t res = 0;
res += base::trace_event::EstimateMemoryUsage(scheme_whitelist_);
// TODO(dyaroshev): Add support for scoped_refptr in
// base::trace_event::EstimateMemoryUsage.
res += sizeof(URLIndexPrivateData) + private_data_->EstimateMemoryUsage();
return res;
}
void InMemoryURLIndex::ClearPrivateData() {
private_data_->Clear();
}
......@@ -215,14 +227,7 @@ void InMemoryURLIndex::OnHistoryServiceLoaded(
bool InMemoryURLIndex::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* process_memory_dump) {
size_t res = 0;
res += base::trace_event::EstimateMemoryUsage(scheme_whitelist_);
// TODO(dyaroshev): Add support for scoped_refptr in
// base::trace_event::EstimateMemoryUsage.
res += sizeof(URLIndexPrivateData) + private_data_->EstimateMemoryUsage();
size_t res = EstimateMemoryUsage();
const std::string dump_name =
base::StringPrintf("omnibox/in_memory_url_index/0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(this));
......
......@@ -115,6 +115,9 @@ class InMemoryURLIndex : public KeyedService,
// history database.
void Init();
// Estimates the amount of memory used.
size_t EstimateMemoryUsage() const;
// Scans the history index and returns a vector with all scored, matching
// history items. This entry point simply forwards the call on to the
// URLIndexPrivateData class. For a complete description of this function
......
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