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-- Converts event counter from count to rate (num of accesses per ns). 17CREATE PERFETTO FUNCTION _get_rate(event STRING) 18RETURNS TABLE(ts LONG, dur INT, access_rate INT) 19AS 20SELECT 21 ts, 22 lead(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts AS dur, 23 -- Rate of event accesses in a section (i.e. count / dur). 24 value / (lead(ts) OVER (PARTITION BY track_id ORDER BY ts) - ts) AS access_rate 25FROM counter AS c 26JOIN counter_track AS t 27 ON c.track_id = t.id 28WHERE t.name = $event; 29 30-- The rate of L3 misses for each time slice based on the ARM DSU PMU counter's 31-- bus_access event. Units will be in number of L3 misses per ns. The number of 32-- accesses in a given duration can be calculated by multiplying the appropriate 33-- rate with the time in the window of interest. 34CREATE PERFETTO TABLE _arm_l3_miss_rate 35AS 36SELECT 37 ts, dur, access_rate AS l3_miss_rate 38FROM _get_rate("arm_dsu_0/bus_access/_cpu0"); 39 40-- The rate of L3 accesses for each time slice based on the ARM DSU PMU 41-- counter's l3d_cache event. Units will be in number of DDR accesses per ns. 42-- The number of accesses in a given duration can be calculated by multiplying 43-- the appropriate rate with the time in the window of interest. 44CREATE PERFETTO TABLE _arm_l3_hit_rate 45AS 46SELECT 47 ts, dur, access_rate AS l3_hit_rate 48FROM _get_rate("arm_dsu_0/l3d_cache/_cpu0"); 49 50