Skip to content

Commit

Permalink
Merge "add time_to_running_state for the duration between launch and …
Browse files Browse the repository at this point in the history
…app start time." into main
  • Loading branch information
Haiping Yang authored and Gerrit Code Review committed Sep 28, 2023
2 parents e987cfc + d32456b commit e879b2e
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 11 deletions.
5 changes: 4 additions & 1 deletion protos/perfetto/metrics/android/startup_metric.proto
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ message AndroidStartupMetric {

// Timing information spanning the intent received by the
// activity manager to the first frame drawn.
// Next id: 35.
// Next id: 36.
message ToFirstFrame {
// The duration between the intent received and first frame.
optional int64 dur_ns = 1;
Expand Down Expand Up @@ -86,6 +86,9 @@ message AndroidStartupMetric {
// The actual duration of the process start (based on the zygote slice).
optional Slice time_during_start_process = 11;

// The duration from launch to first running state thread of startup process.
optional Slice time_to_running_state = 35;

optional Slice to_post_fork = 18;
optional Slice to_activity_thread_main = 19;
optional Slice to_bind_application = 20;
Expand Down
5 changes: 4 additions & 1 deletion protos/perfetto/metrics/perfetto_merged_metrics.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ message AndroidStartupMetric {

// Timing information spanning the intent received by the
// activity manager to the first frame drawn.
// Next id: 35.
// Next id: 36.
message ToFirstFrame {
// The duration between the intent received and first frame.
optional int64 dur_ns = 1;
Expand Down Expand Up @@ -1862,6 +1862,9 @@ message AndroidStartupMetric {
// The actual duration of the process start (based on the zygote slice).
optional Slice time_during_start_process = 11;

// The duration from launch to first running state thread of startup process.
optional Slice time_to_running_state = 35;

optional Slice to_post_fork = 18;
optional Slice to_activity_thread_main = 19;
optional Slice to_bind_application = 20;
Expand Down
9 changes: 5 additions & 4 deletions python/perfetto/trace_processor/metrics.descriptor
Original file line number Diff line number Diff line change
Expand Up @@ -776,8 +776,8 @@ maxRuntime$
name ( RnameY
threads ( 2?.perfetto.protos.AndroidSimpleperfMetric.PerfEventMetric.ThreadRthreads
total (Rtotal
.
4protos/perfetto/metrics/android/startup_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto"�-
/
4protos/perfetto/metrics/android/startup_metric.protoperfetto.protos6protos/perfetto/metrics/android/process_metadata.proto"�.
AndroidStartupMetricG
startup ( 2-.perfetto.protos.AndroidStartupMetric.StartupRstartup�
TaskStateBreakdown$
Expand All @@ -794,7 +794,7 @@ maxRuntime$
unknown (Runknown5
Slice
dur_ns (RdurNs
dur_ms (RdurMs�
dur_ms (RdurMs�
ToFirstFrame
dur_ns (RdurNs
dur_ms (RdurMsr
Expand All @@ -812,7 +812,8 @@ maxRuntime$
time_get_resources ( 2+.perfetto.protos.AndroidStartupMetric.SliceRtimeGetResourcesf
time_before_start_process
( 2+.perfetto.protos.AndroidStartupMetric.SliceRtimeBeforeStartProcessf
time_during_start_process ( 2+.perfetto.protos.AndroidStartupMetric.SliceRtimeDuringStartProcessM
time_during_start_process ( 2+.perfetto.protos.AndroidStartupMetric.SliceRtimeDuringStartProcess^
time_to_running_state# ( 2+.perfetto.protos.AndroidStartupMetric.SliceRtimeToRunningStateM
to_post_fork ( 2+.perfetto.protos.AndroidStartupMetric.SliceR
toPostForkb
to_activity_thread_main ( 2+.perfetto.protos.AndroidStartupMetric.SliceRtoActivityThreadMain[
Expand Down
2 changes: 2 additions & 0 deletions src/trace_processor/metrics/sql/android/android_startup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ SELECT
SELECT startup_slice_proto(ts - launches.ts)
FROM ZYGOTE_FORK_FOR_LAUNCH(launches.startup_id)
),
'time_to_running_state',
time_to_running_state_for_launch(launches.startup_id),
'time_jit_thread_pool_on_cpu', NULL_IF_EMPTY(startup_slice_proto(
thread_time_for_launch_state_and_thread(
launches.startup_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,15 @@ RETURNS INT AS
SELECT SUM(dur)
FROM launch_thread_state_dur_sum l
WHERE l.startup_id = $startup_id AND state GLOB $state AND thread_name = $thread_name;


-- Given a launch id, returns the duration between the launch and a running state thread of
-- startup process.
CREATE PERFETTO FUNCTION time_to_running_state_for_launch(startup_id LONG)
RETURNS PROTO AS
SELECT NULL_IF_EMPTY(
STARTUP_SLICE_PROTO(
IIF(MIN(l.ts) > launches.ts, MIN(l.ts) - launches.ts, NULL)))
FROM launch_threads_by_thread_state l
JOIN android_startups launches USING(startup_id)
WHERE l.startup_id = $startup_id AND l.state = "Running";
4 changes: 4 additions & 0 deletions test/trace_processor/diff_tests/startup/android_startup.out
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ android_startup {
dur_ms: 1e-06
}
dur_ms: 0.000108
time_to_running_state {
dur_ns: 8
dur_ms: 8e-06
}
}
activity_hosting_process_count: 1
process {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ android_startup {
dur_ns: 2
dur_ms: 2e-06
}
time_to_running_state {
dur_ns: 55
dur_ms: 5.5e-05
}
}
activity_hosting_process_count: 1
process {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ android_startup {
dur_ns: 20000000000
dur_ms: 20000.0
}
time_to_running_state {
dur_ns: 55000000000
dur_ms: 55000.0
}
}
activity_hosting_process_count: 1
process {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ android_startup {
mcycles_by_core_type {
unknown: 103
}
time_to_running_state {
dur_ns: 78000000000
dur_ms: 78000.0
}
}
activity_hosting_process_count: 1
process {
Expand All @@ -77,6 +81,11 @@ android_startup {
method: "performCreate"
ts_method_start: 188000000000
}
activities {
name: "com.google.android.calendar.MainActivity"
method: "performResume"
ts_method_start: 193000000000
}
optimization_status {
odex_status: "up-to-date"
compilation_filter: "speed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def to_s(ts):
trace.add_atrace_end(ts=to_s(192), tid=3, pid=3)
trace.add_atrace_end(ts=to_s(192), tid=3, pid=3)
trace.add_atrace_begin(
ts=193,
ts=to_s(193),
tid=3,
pid=3,
buf='performResume:com.google.android.calendar.MainActivity')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android_startup {
dur_ms: 8000.0
}
time_bind_application {
dur_ns: 9000000000
dur_ms: 9000.0
dur_ns: 10000000000
dur_ms: 10000.0
}
time_activity_start {
dur_ns: 1000000000
Expand Down Expand Up @@ -55,6 +55,10 @@ android_startup {
mcycles_by_core_type {
unknown: 103
}
time_to_running_state {
dur_ns: 78000000000
dur_ms: 78000.0
}
}
activity_hosting_process_count: 1
process {
Expand All @@ -77,6 +81,11 @@ android_startup {
method: "performCreate"
ts_method_start: 188000000000
}
activities {
name: "com.google.android.calendar.MainActivity"
method: "performResume"
ts_method_start: 193000000000
}
optimization_status {
odex_status: "up-to-date"
compilation_filter: "speed-profile"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def to_s(ts):
trace.add_process(3, 1, 'com.google.android.calendar', uid=10001)

trace.add_package_list(
ts=100, name='com.google.android.calendar', uid=10001, version_code=123)
ts=to_s(100), name='com.google.android.calendar', uid=10001, version_code=123)

trace.add_ftrace_packet(cpu=0)

Expand Down Expand Up @@ -67,7 +67,7 @@ def to_s(ts):
trace.add_atrace_end(ts=to_s(192), tid=3, pid=3)
trace.add_atrace_end(ts=to_s(192), tid=3, pid=3)
trace.add_atrace_begin(
ts=193,
ts=to_s(193),
tid=3,
pid=3,
buf='performResume:com.google.android.calendar.MainActivity')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ android_startup {
dur_ns: 3
dur_ms: 3e-06
}

}
activity_hosting_process_count: 1
process {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ android_startup {
dur_ms: 1000
}
dur_ms: 108000
time_to_running_state {
dur_ns: 8000000000
dur_ms: 8000.0
}
}
activity_hosting_process_count: 1
process {
Expand Down

0 comments on commit e879b2e

Please sign in to comment.