Fixed
Status Update
Comments
ra...@google.com <ra...@google.com> #2
deleted
cc...@google.com <cc...@google.com> #3
wu...@gmail.com <wu...@gmail.com> #4
targetPackageOnly needs to be updated to understand process_tracks in addition to thread_tracks. E.g. could union the current result with one around process_tracks, something like:
select * from slice
inner join process_track on slice.track_id = process_track.id
inner join process USING(upid)
where slice.id=23647
ap...@google.com <ap...@google.com> #5
I was thinking, since this is already in beta03
, should we treat it as a bug and not addition to 1.3?
cc...@google.com <cc...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-main
commit 3bfcb889231d3254cf9e8db8df0c2a06f58c152a
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Apr 02 14:14:17 2024
TraceSectionMetric now supports slices created using `Trace.{begin|end}AsyncSection`.
* TraceSectionMetric now additionally looks at Perfetto `process_track`s when looking at named slices.
Test: PerfettoTraceProcessorTest
Fixes: 300434906
Relnote: TraceSectionMetric now supports slices created using `Trace.{begin|end}AsyncSection`.
Change-Id: I91b326e121fcca4b3ce8f65381eea87de796cdd1
M benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/perfetto/PerfettoTraceProcessorTest.kt
M benchmark/benchmark-macro/src/main/java/androidx/benchmark/perfetto/PerfettoTraceProcessor.kt
https://android-review.googlesource.com/3023506
Branch: androidx-main
commit 3bfcb889231d3254cf9e8db8df0c2a06f58c152a
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Apr 02 14:14:17 2024
TraceSectionMetric now supports slices created using `Trace.{begin|end}AsyncSection`.
* TraceSectionMetric now additionally looks at Perfetto `process_track`s when looking at named slices.
Test: PerfettoTraceProcessorTest
Fixes: 300434906
Relnote: TraceSectionMetric now supports slices created using `Trace.{begin|end}AsyncSection`.
Change-Id: I91b326e121fcca4b3ce8f65381eea87de796cdd1
M benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/perfetto/PerfettoTraceProcessorTest.kt
M benchmark/benchmark-macro/src/main/java/androidx/benchmark/perfetto/PerfettoTraceProcessor.kt
Description
Version used:1.1.0-alpha13
Devices/Android versions reproduced on:R
测试工程说明:
测试项目为多进程项目,包名com.example.demo, 但是应用的所有UI界面实现在com.example.demo:ui进程。
问题原因分析:
getMetrics方法中调用StartupTimingQuery.getFrameSubMetrics 参数传入的是PackageName,参数来源是
Marcobenchmark.kt
val iterationResult = userspaceTrace("extract metrics") {
metrics
// capture list of Map<String,Long> per metric
.map { it.getMetrics(Metric.CaptureInfo(
targetPackageName = packageName,
testPackageName = macrobenchPackageName,
startupMode = startupModeMetricHint,
apiLevel = Build.VERSION.SDK_INT
), tracePath) }
// merge into one map
.reduce { sum, element -> sum + element }
}
查询语句:val queryResult = PerfettoTraceProcessor.rawQuery(
absoluteTracePath = absoluteTracePath,
query = getFullQuery(
testProcessName = testPackageName,
targetProcessName = targetPackageName
)
)
private fun getFullQuery(testProcessName: String, targetProcessName: String) = """
------ Select all startup-relevant slices from slice table
SELECT
slice.ts as ts,
slice.dur as dur
FROM slice
INNER JOIN thread_track on slice.track_id =
INNER JOIN thread USING(utid)
INNER JOIN process USING(upid)
WHERE (
(
(
(
(
(
(
)
) OR
(
-- Signals beginning of launch event, only present in API 29+
)
)
------ Add in async slices
UNION
SELECT
slice.ts as ts,
slice.dur as dur
FROM slice
INNER JOIN process_track on slice.track_id =
INNER JOIN process USING(upid)
WHERE (
-- API 23+: "launching: <target>"
-- API 19-22: "launching"
)
ORDER BY ts ASC
""".trimIndent()
会将packagename 作为限制条件,导致查询不到结果。
对于用户,不能修改这个参数,来达到查询正确进程的目的。
修改建议:
(1)对于Metric 对象是特定进程的时候,开放参数传入指定进程名(默认值是包名)。比如:FrameTimingGfxInfoMetric,FrameTimingMetric,StartupTimingMetric。
(2)目前Metric 是sealed的,建议开放给用户,给用户更多自定义Metric 的空间。