-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decouple CUJ pinning from JankCUJ metrics
This allows to prevent pinning the same CUJ multiple times if there are multiple metrics related to it. Also, each metric could be matched by multiple handlers now. Bug: 354119654 Test: opened perfetto with 2 metrics to pin related to the same CUJ. Verified the CUJ is pinned once Change-Id: I26ac544ce78ebb7a6e3734f356e264bcf9d32caf
- Loading branch information
Showing
5 changed files
with
99 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
ui/src/plugins/dev.perfetto.PinAndroidPerfMetrics/handlers/pinCujMetricHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (C) 2024 The Android Open Source Project | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import {CujMetricData, MetricHandler} from './metricUtils'; | ||
import {PluginContextTrace} from '../../../public'; | ||
import {addJankCUJDebugTrack} from '../../dev.perfetto.AndroidCujs'; | ||
import {TrackType} from '../../dev.perfetto.AndroidCujs/trackUtils'; | ||
import {PLUGIN_ID} from '../pluginId'; | ||
|
||
/** Pins a single CUJ from CUJ scoped metrics. */ | ||
class PinCujMetricHandler implements MetricHandler { | ||
/** | ||
* Matches metric key & return parsed data if successful. | ||
* | ||
* @param {string} metricKey The metric key to match. | ||
* @returns {CujMetricData | undefined} Parsed data or undefined if no match. | ||
*/ | ||
public match(metricKey: string): CujMetricData | undefined { | ||
const matcher = /perfetto_cuj_(?<process>.*)-(?<cujName>.*)-.*-missed_.*/; | ||
const match = matcher.exec(metricKey); | ||
if (!match?.groups) { | ||
return undefined; | ||
} | ||
return { | ||
cujName: match.groups.cujName, | ||
}; | ||
} | ||
|
||
/** | ||
* Adds the debug tracks for cuj Scoped jank metrics | ||
* registerStaticTrack used when plugin adds tracks onTraceload() | ||
* addDebugSliceTrack used for adding tracks using the command | ||
* | ||
* @param {CujMetricData} metricData Parsed metric data for the cuj scoped jank | ||
* @param {PluginContextTrace} ctx PluginContextTrace for trace related properties and methods | ||
* @param {TrackType} type 'static' for onTraceload and 'debug' for command | ||
* @returns {void} Adds one track for Jank CUJ slice and one for Janky CUJ frames | ||
*/ | ||
public async addMetricTrack( | ||
metricData: CujMetricData, | ||
ctx: PluginContextTrace, | ||
type: TrackType, | ||
) { | ||
this.pinSingleCuj(ctx, metricData.cujName, type); | ||
} | ||
|
||
private pinSingleCuj( | ||
ctx: PluginContextTrace, | ||
cujName: string, | ||
type: TrackType, | ||
) { | ||
const uri = `${PLUGIN_ID}#PinCuj#${cujName}`; | ||
const trackName = `Jank CUJ: ${cujName}`; | ||
addJankCUJDebugTrack(ctx, trackName, type, cujName, uri); | ||
} | ||
} | ||
|
||
export const pinCujInstance = new PinCujMetricHandler(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters