Skip to content

Commit

Permalink
GPU Counters should not be sorted alphabetically in the perfetto capt…
Browse files Browse the repository at this point in the history
…ure results (#108)

* GPU Counters should not be sorted alphabetically in the perfetto capture results

* Only sort ThreadTracks

* Update ui/src/common/state.ts

Co-authored-by: Christian W. Damus <[email protected]>

---------

Co-authored-by: Christian W. Damus <[email protected]>
  • Loading branch information
ALevansSamsung and cdamus authored May 10, 2024
1 parent 8b68253 commit 49a8f98
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ui/src/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,10 @@ export const StateActions = {
const coll = new Intl.Collator([], {sensitivity: 'base', numeric: true});
for (const group of Object.values(state.trackGroups)) {
group.sortOrder.sort((a: string, b: string) => {
if (state.tracks[a] && state.tracks[b]) {
if (state.tracks[a] && state.tracks[b] &&
// Check if sort key for tracks are ThreadTrackSortKeys
ThreadTrackSortKey.is(state.tracks[a].trackSortKey) &&
ThreadTrackSortKey.is(state.tracks[b].trackSortKey)) {
const aRank = getFullKey(a);
const bRank = getFullKey(b);
for (let i = 0; i < aRank.length; i++) {
Expand Down
6 changes: 6 additions & 0 deletions ui/src/common/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ export type ThreadTrackSortKey = {
priority: InThreadTrackSortKey,
}

export namespace ThreadTrackSortKey {
export function is(key: unknown): key is ThreadTrackSortKey {
return typeof key === 'object' && !!key && 'utid' in key && 'priority' in key && typeof key.utid === 'number';
}
}

// Sort key for all tracks: both thread-associated and non-thread associated.
export type TrackSortKey = PrimaryTrackSortKey|ThreadTrackSortKey;

Expand Down
2 changes: 1 addition & 1 deletion ui/src/tracks/counter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ async function globalTrackProvider(engine: EngineProxy): Promise<TrackInfo[]> {
from gpu_counter_track
where name != 'gpufreq'
)
order by name
order by id
`);

// Add global or GPU counter tracks that are not bound to any pid/tid.
Expand Down

0 comments on commit 49a8f98

Please sign in to comment.