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 16INCLUDE PERFETTO MODULE sched.runnable; 17 18CREATE PERFETTO VIEW _sched_with_thread_state_join AS 19SELECT 20 thread_state.id AS thread_state_id, 21 sched.id AS sched_id 22FROM sched 23JOIN thread_state 24 USING (utid, ts, dur); 25 26-- Scheduling latency of running thread states. 27-- For each time the thread was running, returns the duration of the runnable 28-- state directly before. 29CREATE PERFETTO TABLE sched_latency_for_running_interval ( 30 -- Running state of the thread. 31 thread_state_id JOINID(thread_state.id), 32 -- Id of a corresponding slice in a `sched` table. 33 sched_id JOINID(sched.id), 34 -- Thread with running state. 35 utid JOINID(thread.id), 36 -- Runnable state before thread is "running". Duration of this thread state 37 -- is `latency_dur`. One of `thread_state.id`. 38 runnable_latency_id JOINID(thread_state.id), 39 -- Scheduling latency of thread state. Duration of thread state with 40 -- `runnable_latency_id`. 41 latency_dur LONG 42) AS 43SELECT 44 r.id AS thread_state_id, 45 sched_id, 46 utid, 47 prev_runnable_id AS runnable_latency_id, 48 dur AS latency_dur 49FROM sched_previous_runnable_on_thread AS r 50JOIN thread_state AS prev_ts 51 ON prev_runnable_id = prev_ts.id 52JOIN _sched_with_thread_state_join 53 ON thread_state_id = r.id; 54