• 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
17-- All scheduled jobs and their latencies.
18--
19-- The table is populated by ATrace using the system server ATrace category
20-- (`atrace_categories: "ss"`). You can also set the `atrace_apps` of interest.
21--
22-- This differs from the `android_job_scheduler_states` table
23-- in the `android.job_scheduler_states` module which is populated
24-- by the `ScheduledJobStateChanged` atom.
25--
26-- Using `android_job_scheduler_states` is preferred when the
27-- `ATOM_SCHEDULED_JOB_STATE_CHANGED` is available in the trace since
28-- it includes the constraint, screen, or charging state changes for
29-- each job in a trace.
30CREATE PERFETTO TABLE android_job_scheduler_events (
31  -- Id of the scheduled job assigned by the app developer.
32  job_id LONG,
33  -- Uid of the process running the scheduled job.
34  uid LONG,
35  -- Package name of the process running the scheduled job.
36  package_name STRING,
37  -- Service component name of the scheduled job.
38  job_service_name STRING,
39  -- Thread track id of the job scheduler event slice.
40  track_id JOINID(track.id),
41  -- Slice id of the job scheduler event slice.
42  id LONG,
43  -- Timestamp the job was scheduled.
44  ts TIMESTAMP,
45  -- Duration of the scheduled job.
46  dur DURATION
47) AS
48SELECT
49  cast_int!(STR_SPLIT(slice.name, '#', 1)) AS job_id,
50  cast_int!(STR_SPLIT(STR_SPLIT(slice.name, '<', 1), '>', 0)) AS uid,
51  str_split(str_split(slice.name, '>', 1), '/', 0) AS package_name,
52  str_split(str_split(slice.name, '/', 1), '#', 0) AS job_service_name,
53  track_id,
54  slice.id,
55  slice.ts,
56  iif(slice.dur = -1, trace_end() - slice.ts, slice.dur) AS dur
57FROM slice
58JOIN process_track
59  ON slice.track_id = process_track.id
60JOIN process
61  ON process.upid = process_track.upid
62WHERE
63  process.name = 'system_server'
64  AND slice.name GLOB '*job*'
65  AND process_track.name = 'JobScheduler';
66