• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2024 The Android Open Source Project
3--
4-- Licensed under the Apache License, Version 2.0 (the "License");
5-- you may not use this file except in compliance with the License.
6-- You may obtain a copy of the License at
7--
8--     https://www.apache.org/licenses/LICENSE-2.0
9--
10-- Unless required by applicable law or agreed to in writing, software
11-- distributed under the License is distributed on an "AS IS" BASIS,
12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-- See the License for the specific language governing permissions and
14-- limitations under the License.
15--
16
17SELECT RUN_METRIC('android/process_metadata.sql');
18
19INCLUDE PERFETTO MODULE android.memory.heap_graph.heap_graph_class_aggregation;
20
21DROP VIEW IF EXISTS java_heap_class_stats_output;
22CREATE PERFETTO VIEW java_heap_class_stats_output AS
23WITH
24-- Group by to build the repeated field by upid, ts
25heap_class_stats_count_protos AS (
26  SELECT
27    upid,
28    graph_sample_ts,
29    RepeatedField(JavaHeapClassStats_TypeCount(
30      'type_name', type_name,
31      'is_libcore_or_array', is_libcore_or_array,
32      'obj_count', obj_count,
33      'size_bytes', size_bytes,
34      'native_size_bytes', native_size_bytes,
35      'reachable_obj_count', reachable_obj_count,
36      'reachable_size_bytes', reachable_size_bytes,
37      'reachable_native_size_bytes', reachable_native_size_bytes,
38      'dominated_obj_count', dominated_obj_count,
39      'dominated_size_bytes', dominated_size_bytes,
40      'dominated_native_size_bytes', dominated_native_size_bytes
41    )) AS count_protos
42  FROM android_heap_graph_class_aggregation s
43  GROUP BY 1, 2
44),
45-- Group by to build the repeated field by upid
46heap_class_stats_sample_protos AS (
47  SELECT
48    upid,
49    RepeatedField(JavaHeapClassStats_Sample(
50      'ts', graph_sample_ts,
51      'type_count', count_protos
52    )) AS sample_protos
53  FROM heap_class_stats_count_protos
54  GROUP BY 1
55)
56SELECT JavaHeapClassStats(
57  'instance_stats', RepeatedField(JavaHeapClassStats_InstanceStats(
58    'upid', upid,
59    'process', process_metadata.metadata,
60    'samples', sample_protos
61  )))
62FROM heap_class_stats_sample_protos JOIN process_metadata USING (upid);
63