• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2023 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-- TODO(b/329344794): Rewrite to fetch data from other tables than `raw`.
17
18-- Aggregates f2fs IO and latency stats by counter name.
19CREATE PERFETTO VIEW _android_io_f2fs_counter_stats (
20  -- Counter name on which all the other values are aggregated on.
21  name STRING,
22  -- Sum of all counter values for the counter name.
23  sum DOUBLE,
24  -- Max of all counter values for the counter name.
25  max DOUBLE,
26  -- Min of all counter values for the counter name.
27  min DOUBLE,
28  -- Duration between the first and last counter value for the counter name.
29  dur DURATION,
30  -- Count of all the counter values for the counter name.
31  count LONG,
32  -- Avergate of all the counter values for the counter name.
33  avg DOUBLE
34) AS
35SELECT
36  str_split(counter_track.name, '].', 1) AS name,
37  sum(counter.value) AS sum,
38  max(counter.value) AS max,
39  min(counter.value) AS min,
40  max(ts) - min(ts) AS dur,
41  count(ts) AS count,
42  avg(counter.value) AS avg
43FROM counter
44JOIN counter_track
45  ON counter_track.id = counter.track_id AND counter_track.name GLOB '*f2fs*'
46GROUP BY
47  name
48ORDER BY
49  sum DESC;
50
51-- Aggregates f2fs_write stats by inode and thread.
52CREATE PERFETTO VIEW _android_io_f2fs_write_stats (
53  -- Utid of the thread.
54  utid JOINID(thread.id),
55  -- Tid of the thread.
56  tid LONG,
57  -- Name of the thread.
58  thread_name STRING,
59  -- Upid of the process.
60  upid JOINID(process.id),
61  -- Pid of the process.
62  pid LONG,
63  -- Name of the thread.
64  process_name STRING,
65  -- Inode number of the file being written.
66  ino LONG,
67  -- Device node number of the file being written.
68  dev LONG,
69  -- Total number of bytes written on this file by the |utid|.
70  bytes LONG,
71  -- Total count of write requests for this file.
72  write_count LONG
73) AS
74WITH
75  f2fs_write_end AS (
76    SELECT
77      *,
78      extract_arg(arg_set_id, 'len') AS len,
79      extract_arg(arg_set_id, 'dev') AS dev,
80      extract_arg(arg_set_id, 'ino') AS ino,
81      extract_arg(arg_set_id, 'copied') AS copied
82    FROM ftrace_event
83    WHERE
84      name GLOB 'f2fs_write_end*'
85  )
86SELECT
87  thread.utid,
88  thread.tid,
89  thread.name AS thread_name,
90  process.upid,
91  process.pid,
92  process.name AS process_name,
93  f.ino,
94  f.dev,
95  sum(copied) AS bytes,
96  count(len) AS write_count
97FROM f2fs_write_end AS f
98JOIN thread
99  USING (utid)
100JOIN process
101  USING (upid)
102GROUP BY
103  utid,
104  ino,
105  dev
106ORDER BY
107  bytes DESC;
108
109-- Aggregates f2fs write stats. Counts distinct datapoints, total write operations,
110-- and bytes written
111CREATE PERFETTO VIEW _android_io_f2fs_aggregate_write_stats (
112  -- Total number of writes in the trace.
113  total_write_count LONG,
114  -- Number of distinct processes.
115  distinct_processes LONG,
116  -- Total number of bytes written.
117  total_bytes_written LONG,
118  -- Count of distinct devices written to.
119  distinct_device_count LONG,
120  -- Count of distinct inodes written to.
121  distinct_inode_count LONG,
122  -- Count of distinct threads writing.
123  distinct_thread_count LONG
124) AS
125SELECT
126  sum(write_count) AS total_write_count,
127  count(DISTINCT pid) AS distinct_processes,
128  sum(bytes) AS total_bytes_written,
129  count(DISTINCT dev) AS distinct_device_count,
130  count(DISTINCT ino) AS distinct_inode_count,
131  count(DISTINCT tid) AS distinct_thread_count
132FROM _android_io_f2fs_write_stats;
133