-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tp: add summary of heap graph class tree
Allows easy querying of the graph. Change-Id: Iba1fd1db7171a2ba00e6e7397898ba70bfc6c44f
- Loading branch information
1 parent
6715e74
commit 2e635db
Showing
5 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/trace_processor/perfetto_sql/stdlib/android/memory/heap_graph/class_summary_tree.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
-- | ||
-- Copyright 2024 The Android Open Source Project | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- https://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed ON an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
INCLUDE PERFETTO MODULE android.memory.heap_graph.class_tree; | ||
INCLUDE PERFETTO MODULE graphs.scan; | ||
|
||
CREATE PERFETTO TABLE _heap_graph_class_tree_cumulatives AS | ||
SELECT * | ||
FROM _graph_aggregating_scan!( | ||
( | ||
SELECT id AS source_node_id, parent_id AS dest_node_id | ||
FROM _heap_graph_class_tree | ||
WHERE parent_id IS NOT NULL | ||
), | ||
( | ||
SELECT | ||
p.id, | ||
p.self_count AS cumulative_count, | ||
p.self_size AS cumulative_size | ||
FROM _heap_graph_class_tree p | ||
LEFT JOIN _heap_graph_class_tree c ON c.parent_id = p.id | ||
WHERE c.id IS NULL | ||
), | ||
(cumulative_count, cumulative_size), | ||
( | ||
WITH agg AS ( | ||
SELECT | ||
t.id, | ||
SUM(t.cumulative_count) AS child_count, | ||
SUM(t.cumulative_size) AS child_size | ||
FROM $table t | ||
GROUP BY t.id | ||
) | ||
SELECT | ||
a.id, | ||
a.child_count + r.self_count as cumulative_count, | ||
a.child_size + r.self_size as cumulative_size | ||
FROM agg a | ||
JOIN _heap_graph_class_tree r USING (id) | ||
) | ||
) a | ||
ORDER BY id; | ||
|
||
-- Table containing all the Android heap graphs in the trace converted to a | ||
-- shortest-path tree and then aggregated by class name. | ||
-- | ||
-- This table contains a "flamegraph-like" representation of the contents of the | ||
-- heap graph. | ||
CREATE PERFETTO TABLE android_heap_graph_class_summary_tree( | ||
-- The timestamp the heap graph was dumped at. | ||
graph_sample_ts INT, | ||
-- The upid of the process. | ||
upid INT, | ||
-- The id of the node in the class tree. | ||
id INT, | ||
-- The parent id of the node in the class tree or NULL if this is the root. | ||
parent_id INT, | ||
-- The name of the class. | ||
name STRING, | ||
-- A string describing the type of Java root if this node is a root or NULL | ||
-- if this node is not a root. | ||
root_type STRING, | ||
-- The count of objects with the same class name and the same path to the | ||
-- root. | ||
self_count INT, | ||
-- The size of objects with the same class name and the same path to the | ||
-- root. | ||
self_size INT, | ||
-- The sum of `self_count` of this node and all descendants of this node. | ||
cumulative_count INT, | ||
-- The sum of `self_size` of this node and all descendants of this node. | ||
cumulative_size INT | ||
) AS | ||
SELECT | ||
t.graph_sample_ts, | ||
t.upid, | ||
t.id, | ||
t.parent_id, | ||
t.name, | ||
t.root_type, | ||
t.self_count, | ||
t.self_size, | ||
c.cumulative_count, | ||
c.cumulative_size | ||
FROM _heap_graph_class_tree t | ||
JOIN _heap_graph_class_tree_cumulatives c USING (id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters