Status Update
Comments
cc...@google.com <cc...@google.com> #2
What would you like the metric to display? the amount of time spent in composition, or number of times something composes? You can now write a custom TraceMetric that does this in the latest alphas of macrobench:
// warning - copied/pasted and edited, hasn't been tested
object : TraceMetric() {
override fun getResult(
captureInfo: CaptureInfo,
traceSession: PerfettoTraceProcessor.Session
): List<Measurement> {
val durationsNs = traceSession.query(
"""
SELECT * FROM slice
INNER JOIN thread_track on slice.track_id = thread_track.id
INNER JOIN thread USING(utid)
INNER JOIN process USING(upid)
WHERE process.name LIKE "${captureInfo.targetPackageName}"
AND slice.name LIKE "com.myapp.Item (%)"
""".trimIndent()
).map { it.long("dur") }
return listOf(
Measurement("RecomposeItemDurNs", durations.sumOf { it } / 1_000_000.0) // convert ns -> ms
Measurement("RecomposeItemCount", durations.size * 1.0)
)
}
}
Note that for this to work, you'll need to pass the instrumentation argument that enables recomposition tracing capture:
If this sort of thing is generally useful, we could definitely add it to the library.
ys...@google.com <ys...@google.com> #3
That seems to work nicely
MarqueeBenchmark_noMarquee
CanvasRecomposeCount min 55.0, median 55.0, max 55.0
CanvasRecomposeDurMs min 8.3, median 8.3, max 8.3
ml...@google.com <ml...@google.com> #4
Just a question -- this looks (almost) exactly the same as TraceSectionMetric
with Mode.Sum
. Could we consider extending that to also have the count
value?
be...@google.com <be...@google.com> #5
This is pretty cool and no doubt useful. Part of me wonders if this is something we actually want to add though, aren't you testing internal Compose details at this point?
If you already have a benchmark set up, isn't frame timing and startup time a better actual metric to track than recomposition count? Hypothetically, Compose could make a behaviour change to the rules for recomposition and then your test could be marked as regressed on composition count but not on actual frame timing.
ra...@google.com <ra...@google.com> #6
I don't think composition count counts as implementation detail though; and more importantly this is a very stable metric when compared to frame timing.
Definitely worth pursuing.
ml...@google.com <ml...@google.com> #7
recomposition count without verifying it's actually a performance (frame
timing) problem.
On Tue, May 30, 2023, 19:55 rahulrav <buganizer-system+rahulrav@google.com>
wrote:
cc...@google.com <cc...@google.com> #8
+1 to the Mode.Count
idea, which makes this much easier to setup without clearly pushing people in that direction.
ap...@google.com <ap...@google.com> #9
Branch: androidx-main
commit c03d654ce041fc2940842924f87cd2ccc3b9fb1b
Author: Tomáš Mlynarič <mlykotom@google.com>
Date: Wed Jun 07 15:18:46 2023
Add count measurement to TraceSectionMetric with Mode.Sum
Example:
ScrollForYouFeedBenchmark_scrollFeedCompilationFull
dateFormattedCount min 13.0, median 15.5, max 20.0
dateFormattedDurMs min 1.4, median 1.9, max 2.4
RelNote: Add count measurement to TraceSectionMetric with Mode.Sum
Test: Updated
Fixes: 264398606
Change-Id: Ic121ac1432a973413b5318ccf5df6a2e1556419a
M benchmark/benchmark-macro/src/androidTest/java/androidx/benchmark/macro/TraceSectionMetricTest.kt
M benchmark/benchmark-macro/src/main/java/androidx/benchmark/macro/Metric.kt
pr...@google.com <pr...@google.com> #10
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.benchmark:benchmark-macro:1.2.0-alpha16
Description
Component used:
Version used:
Devices/Android versions reproduced on:
If this is a bug in the library, we would appreciate if you could attach:
- Sample project to trigger the issue.
- A screenrecord or screenshots showing the issue (if UI related).