Commit 3371fa5a authored by Jasper Chapman-Black's avatar Jasper Chapman-Black Committed by Commit Bot

SuperSize: Caspian: Use symbol PSS instead of size

This prevents double-counting the size contribution of symbols
with aliases: rather than each of N aliases having size S, they
will each have PSS S/N.

Bug: 1011921
Change-Id: I3add28981d543a5b56dd2e77f1bbeb3ee44ddd17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891141
Commit-Queue: Jasper Chapman-Black <jaspercb@chromium.org>
Reviewed-by: default avatarSamuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710996}
parent f701be68
...@@ -48,7 +48,7 @@ void BuildTree(bool group_by_component, ...@@ -48,7 +48,7 @@ void BuildTree(bool group_by_component,
if (minimum_size_bytes > 0) { if (minimum_size_bytes > 0) {
filters.push_back([minimum_size_bytes](const Symbol& sym) -> bool { filters.push_back([minimum_size_bytes](const Symbol& sym) -> bool {
return sym.size >= minimum_size_bytes; return sym.pss() >= minimum_size_bytes;
}); });
} }
......
...@@ -99,7 +99,7 @@ NodeStats::~NodeStats() = default; ...@@ -99,7 +99,7 @@ NodeStats::~NodeStats() = default;
NodeStats::NodeStats(SectionId sectionId, NodeStats::NodeStats(SectionId sectionId,
int32_t count, int32_t count,
int32_t highlight, int32_t highlight,
int32_t size) { float size) {
child_stats[sectionId] = {count, highlight, size}; child_stats[sectionId] = {count, highlight, size};
} }
...@@ -124,7 +124,7 @@ NodeStats& NodeStats::operator+=(const NodeStats& other) { ...@@ -124,7 +124,7 @@ NodeStats& NodeStats::operator+=(const NodeStats& other) {
SectionId NodeStats::ComputeBiggestSection() const { SectionId NodeStats::ComputeBiggestSection() const {
SectionId ret = SectionId::kNone; SectionId ret = SectionId::kNone;
int32_t max = 0; float max = 0.0f;
for (auto& pair : child_stats) { for (auto& pair : child_stats) {
if (pair.second.size > max) { if (pair.second.size > max) {
ret = pair.first; ret = pair.first;
......
...@@ -44,6 +44,11 @@ struct Symbol { ...@@ -44,6 +44,11 @@ struct Symbol {
Symbol(); Symbol();
Symbol(const Symbol& other); Symbol(const Symbol& other);
float pss() const {
int alias_count = aliases ? aliases->size() : 1;
return static_cast<float>(size) / alias_count;
}
int32_t address = 0; int32_t address = 0;
int32_t size = 0; int32_t size = 0;
int32_t flags = 0; int32_t flags = 0;
...@@ -81,7 +86,7 @@ struct SizeInfo { ...@@ -81,7 +86,7 @@ struct SizeInfo {
struct Stat { struct Stat {
int32_t count = 0; int32_t count = 0;
int32_t highlight = 0; int32_t highlight = 0;
int32_t size = 0; float size = 0.0f;
void operator+=(const Stat& other) { void operator+=(const Stat& other) {
count += other.count; count += other.count;
...@@ -93,7 +98,7 @@ struct Stat { ...@@ -93,7 +98,7 @@ struct Stat {
struct NodeStats { struct NodeStats {
NodeStats(); NodeStats();
~NodeStats(); ~NodeStats();
NodeStats(SectionId section, int32_t count, int32_t highlight, int32_t size); NodeStats(SectionId section, int32_t count, int32_t highlight, float size);
void WriteIntoJson(Json::Value* out) const; void WriteIntoJson(Json::Value* out) const;
NodeStats& operator+=(const NodeStats& other); NodeStats& operator+=(const NodeStats& other);
SectionId ComputeBiggestSection() const; SectionId ComputeBiggestSection() const;
...@@ -109,7 +114,7 @@ struct TreeNode { ...@@ -109,7 +114,7 @@ struct TreeNode {
std::string_view id_path; std::string_view id_path;
const char* src_path = nullptr; const char* src_path = nullptr;
const char* component = nullptr; const char* component = nullptr;
int32_t size = 0; float size = 0.0f;
NodeStats node_stats; NodeStats node_stats;
int32_t flags = 0; int32_t flags = 0;
int32_t short_name_index = 0; int32_t short_name_index = 0;
......
...@@ -123,9 +123,10 @@ void TreeBuilder::AddFileEntry(const std::string_view source_path, ...@@ -123,9 +123,10 @@ void TreeBuilder::AddFileEntry(const std::string_view source_path,
TreeNode* symbol_node = new TreeNode(); TreeNode* symbol_node = new TreeNode();
symbol_node->container_type = ContainerType::kSymbol; symbol_node->container_type = ContainerType::kSymbol;
symbol_node->id_path = sym->full_name; symbol_node->id_path = sym->full_name;
symbol_node->size = sym->size; symbol_node->size = sym->pss();
symbol_node->node_stats = NodeStats( symbol_node->node_stats =
size_info_->ShortSectionName(sym->section_name), 1, 0, sym->size); NodeStats(size_info_->ShortSectionName(sym->section_name), 1, 0,
symbol_node->size);
AttachToParent(symbol_node, file_node); AttachToParent(symbol_node, file_node);
} }
......
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