• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2023 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import {
16  BreakdownTrackAggType,
17  BreakdownTracks,
18} from '../../components/tracks/breakdown_tracks';
19import {PerfettoPlugin} from '../../public/plugin';
20import {Trace} from '../../public/trace';
21
22export default class implements PerfettoPlugin {
23  static readonly id = 'dev.perfetto.AndroidBinderVizPlugin';
24
25  async onTraceLoad(ctx: Trace): Promise<void> {
26    const binderCounterBreakdowns = new BreakdownTracks({
27      trace: ctx,
28      trackTitle: 'Binder Transaction Counts',
29      modules: ['android.binder', 'android.binder_breakdown'],
30      aggregationType: BreakdownTrackAggType.COUNT,
31      aggregation: {
32        columns: [
33          'server_process',
34          '(IFNULL(interface, "unknown"))',
35          '(IFNULL(method_name, "unknown"))',
36          '(client_process || ":" || client_upid)',
37          '(client_thread || ":" ||  client_utid)',
38        ],
39        tsCol: 'client_ts',
40        durCol: 'client_dur',
41        tableName: 'android_binder_txns',
42      },
43      slice: {
44        columns: ['aidl_name'],
45        tableName: 'android_binder_txns',
46        tsCol: 'client_ts',
47        durCol: 'client_dur',
48      },
49      pivots: {
50        columns: ['reason_type', 'reason'],
51        tableName: 'android_binder_client_server_breakdown',
52        tsCol: 'ts',
53        durCol: 'dur',
54        joins: [
55          {
56            joinTableName: 'android_binder_client_server_breakdown',
57            joinColumns: ['binder_txn_id'],
58          },
59        ],
60      },
61    });
62
63    ctx.workspace.addChildInOrder(await binderCounterBreakdowns.createTracks());
64  }
65}
66