@@ -25,15 +25,10 @@ import ThreadPlugin from '../dev.perfetto.Thread';
2525import { createPerfettoIndex } from '../../trace_processor/sql_utils' ;
2626import { uuidv4Sql } from '../../base/uuid' ;
2727import {
28- Config as ProcessSchedulingTrackConfig ,
29- PROCESS_SCHEDULING_TRACK_KIND ,
30- ProcessSchedulingTrack ,
31- } from './process_scheduling_track' ;
32- import {
33- Config as ProcessSummaryTrackConfig ,
34- PROCESS_SUMMARY_TRACK_KIND ,
35- ProcessSummaryTrack ,
36- } from './process_summary_track' ;
28+ Config as SliceTrackSummaryConfig ,
29+ SLICE_TRACK_SUMMARY_KIND ,
30+ SliceTrackSummary ,
31+ } from './slice_track_summary' ;
3732
3833// This plugin is responsible for adding summary tracks for process and thread
3934// groups.
@@ -47,20 +42,22 @@ export default class implements PerfettoPlugin {
4742 }
4843
4944 private async addProcessTrackGroups ( ctx : Trace ) : Promise < void > {
50- // Makes the queries in `ProcessSchedulingTrack` significantly faster.
45+ // Makes the queries in `SliceTrackSummary` significantly faster when using
46+ // scheduling data.
5147 // TODO(lalitm): figure out a better way to do this without hardcoding this
5248 // here.
5349 await createPerfettoIndex ( {
5450 engine : ctx . engine ,
5551 name : `__process_scheduling_${ uuidv4Sql ( ) } ` ,
5652 on : `__intrinsic_sched_slice(utid)` ,
5753 } ) ;
58- // Makes the queries in `ProcessSummaryTrack` significantly faster.
54+ // Makes the queries in `SliceTrackSummary` significantly faster when using
55+ // slice data.
5956 // TODO(lalitm): figure out a better way to do this without hardcoding this
6057 // here.
6158 await createPerfettoIndex ( {
6259 engine : ctx . engine ,
63- name : `__process_summary_ ${ uuidv4Sql ( ) } ` ,
60+ name : `__slice_track_summary_ ${ uuidv4Sql ( ) } ` ,
6461 on : `__intrinsic_slice(track_id)` ,
6562 } ) ;
6663
@@ -171,39 +168,28 @@ export default class implements PerfettoPlugin {
171168 // for additional details.
172169 isBootImageProfiling && chips . push ( 'boot image profiling' ) ;
173170
174- if ( hasSched ) {
175- const config : ProcessSchedulingTrackConfig = {
176- pidForColor,
177- upid,
178- utid,
179- } ;
180-
181- ctx . tracks . registerTrack ( {
182- uri,
183- tags : {
184- kinds : [ PROCESS_SCHEDULING_TRACK_KIND ] ,
185- } ,
186- chips,
187- renderer : new ProcessSchedulingTrack ( ctx , config , cpuCount , threads ) ,
188- subtitle,
189- } ) ;
190- } else {
191- const config : ProcessSummaryTrackConfig = {
192- pidForColor,
193- upid,
194- utid,
195- } ;
171+ const config : SliceTrackSummaryConfig = {
172+ pidForColor,
173+ upid,
174+ utid,
175+ } ;
196176
197- ctx . tracks . registerTrack ( {
177+ ctx . tracks . registerTrack ( {
178+ uri,
179+ tags : {
180+ kinds : [ SLICE_TRACK_SUMMARY_KIND ] ,
181+ } ,
182+ chips,
183+ renderer : new SliceTrackSummary (
184+ ctx ,
198185 uri ,
199- tags : {
200- kinds : [ PROCESS_SUMMARY_TRACK_KIND ] ,
201- } ,
202- chips,
203- renderer : new ProcessSummaryTrack ( ctx . engine , config ) ,
204- subtitle,
205- } ) ;
206- }
186+ config ,
187+ cpuCount ,
188+ threads ,
189+ hasSched ,
190+ ) ,
191+ subtitle,
192+ } ) ;
207193 }
208194 }
209195
@@ -246,7 +232,14 @@ export default class implements PerfettoPlugin {
246232 return ;
247233 }
248234
249- const config : ProcessSummaryTrackConfig = {
235+ // Get CPU count for kernel thread summary
236+ const cpuCountResult = await engine . query ( `
237+ SELECT COUNT(*) as cpu_count FROM cpu WHERE IFNULL(machine_id, 0) = 0
238+ ` ) ;
239+ const cpuCount = cpuCountResult . firstRow ( { cpu_count : NUM } ) . cpu_count ;
240+
241+ const threads = ctx . plugins . getPlugin ( ThreadPlugin ) . getThreadMap ( ) ;
242+ const config : SliceTrackSummaryConfig = {
250243 pidForColor : 2 ,
251244 upid : it . upid ,
252245 utid : it . utid ,
@@ -255,9 +248,16 @@ export default class implements PerfettoPlugin {
255248 ctx . tracks . registerTrack ( {
256249 uri : '/kernel' ,
257250 tags : {
258- kinds : [ PROCESS_SUMMARY_TRACK_KIND ] ,
251+ kinds : [ SLICE_TRACK_SUMMARY_KIND ] ,
259252 } ,
260- renderer : new ProcessSummaryTrack ( ctx . engine , config ) ,
253+ renderer : new SliceTrackSummary (
254+ ctx ,
255+ '/kernel' ,
256+ config ,
257+ cpuCount ,
258+ threads ,
259+ false ,
260+ ) ,
261261 } ) ;
262262 }
263263}
0 commit comments