Commit 4718f57e authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Add detailed memory dump provider URLIndexPrivateData

This CL is adding the code to dump memory usage for inner-structures
used by URLIndexPrivateData.

The purpose of this CL is to estimate the size/count of the pathological
cases and to see which inner strucutures required limits.

NOTE: This CL need to be reverted before the M88 branch point on Nov 12.

Bug: 1068883
Change-Id: I5c4709d7ce7b634aa2ccf5b40bc19d6bff2e77eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2504278
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822249}
parent e6cec66a
......@@ -250,6 +250,10 @@ bool InMemoryURLIndex::OnMemoryDump(
auto* dump = process_memory_dump->CreateAllocatorDump(dump_name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes, res);
// TODO(https://crbug.com/1068883): Remove this code when the bug is fixed.
private_data_->OnMemoryAllocatorDump(dump);
return true;
}
......
......@@ -24,6 +24,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
......@@ -523,6 +524,75 @@ size_t URLIndexPrivateData::EstimateMemoryUsage() const {
return res;
}
// TODO(https://crbug.com/1068883): Remove this code when the bug is fixed.
// This code should be deprecated and removed before M90. This method is not
// merged with EstimateMemoryUsage(...) since it is intended to be removed.
void URLIndexPrivateData::OnMemoryAllocatorDump(
base::trace_event::MemoryAllocatorDump* dump) const {
dump->AddScalar("search_term_cache",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
search_term_cache_.size());
dump->AddScalar("search_term_cache",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(search_term_cache_));
dump->AddScalar("word_list",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
word_list_.size());
dump->AddScalar("word_list",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(word_list_));
dump->AddScalar("available_words",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
available_words_.size());
dump->AddScalar("available_words",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(available_words_));
dump->AddScalar("word_map",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
word_map_.size());
dump->AddScalar("word_map",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(word_map_));
dump->AddScalar("char_word_map",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
char_word_map_.size());
dump->AddScalar("char_word_map",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(char_word_map_));
dump->AddScalar("word_id_history_map",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
word_id_history_map_.size());
dump->AddScalar("word_id_history_map",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(word_id_history_map_));
dump->AddScalar("history_id_word_map",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
history_id_word_map_.size());
dump->AddScalar("history_id_word_map",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(history_id_word_map_));
dump->AddScalar("history_info_map",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
history_info_map_.size());
dump->AddScalar("history_info_map",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(history_info_map_));
dump->AddScalar("word_starts_map",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
word_starts_map_.size());
dump->AddScalar("word_starts_map",
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
base::trace_event::EstimateMemoryUsage(word_starts_map_));
}
bool URLIndexPrivateData::IsUrlRowIndexed(const history::URLRow& row) const {
return history_info_map_.count(row.id()) > 0;
}
......
......@@ -36,6 +36,12 @@ class HistoryDatabase;
class InMemoryURLIndex;
}
namespace base {
namespace trace_event {
class MemoryAllocatorDump;
}
} // namespace base
// Current version of the cache file.
static const int kCurrentCacheFileVersion = 5;
......@@ -145,6 +151,8 @@ class URLIndexPrivateData
// Estimates dynamic memory usage.
// See base/trace_event/memory_usage_estimator.h for more info.
size_t EstimateMemoryUsage() const;
void OnMemoryAllocatorDump(
base::trace_event::MemoryAllocatorDump* dump) const;
// Returns true if |row| is indexed.
bool IsUrlRowIndexed(const history::URLRow& row) const;
......
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