Skip to content

Commit

Permalink
Merge "stdlib: Move deep idle adjustment to be idle exit" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Wu authored and Gerrit Code Review committed Aug 17, 2024
2 parents 0c46b3d + 8451492 commit 8cd7489
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 153 deletions.
19 changes: 8 additions & 11 deletions src/trace_processor/perfetto_sql/stdlib/wattson/cpu_idle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ WITH
idle_prev AS (
SELECT
ts,
dur,
LAG(ts, 1, trace_start()) OVER (PARTITION BY cpu ORDER by ts) as prev_ts,
value AS idle,
cli.value - cli.delta_value AS idle_prev,
cct.cpu
Expand All @@ -47,28 +47,25 @@ WITH
)) AS cli
JOIN cpu_counter_track AS cct ON cli.track_id = cct.id
),
-- Adjusted ts if applicable, which makes the current deep idle state
-- slightly shorter.
-- Adjusted ts if applicable, which makes the current active state longer if
-- it is coming from an idle exit.
idle_mod AS (
SELECT
IIF(
idle_prev = 4294967295 AND idle = 1,
IIF(dur > offset_ns, ts + offset_ns, ts + dur),
idle_prev = 1 AND idle = 4294967295,
-- extend ts backwards by offset_ns at most up to prev_ts
MAX(ts - offset_ns, prev_ts),
ts
) as ts,
-- ts_next is the starting timestamp of the next slice (i.e. end ts of
-- current slice)
ts + dur as ts_next,
cpu,
idle
FROM idle_prev
JOIN _filtered_deep_idle_offsets USING (cpu)
)
SELECT
ts,
lead(ts, 1, trace_end()) OVER (PARTITION BY cpu ORDER by ts) - ts as dur,
LEAD(ts, 1, trace_end()) OVER (PARTITION BY cpu ORDER by ts) - ts as dur,
cpu,
cast_int!(IIF(idle = 4294967295, -1, idle)) AS idle
FROM idle_mod
WHERE ts != ts_next;
FROM idle_mod;

60 changes: 30 additions & 30 deletions test/trace_processor/diff_tests/metrics/android/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,44 +378,44 @@ def test_wattson_app_startup_rails_output(self):
metric_version: 2
period_info {
period_id: 1
period_dur: 384847394
period_dur: 384847255
cpu_subsystem {
estimate_mw: 4567.958008
estimate_mw: 4568.1772
policy0 {
estimate_mw: 578.353088
estimate_mw: 578.31256
cpu0 {
estimate_mw: 149.026062
estimate_mw: 148.99423
}
cpu1 {
estimate_mw: 130.140015
estimate_mw: 130.13142
}
cpu2 {
estimate_mw: 127.601807
estimate_mw: 127.60357
}
cpu3 {
estimate_mw: 171.585205
estimate_mw: 171.58333
}
}
policy4 {
estimate_mw: 684.187256
estimate_mw: 684.18835
cpu4 {
estimate_mw: 344.394531
estimate_mw: 344.39563
}
cpu5 {
estimate_mw: 339.792725
estimate_mw: 339.7927
}
}
policy6 {
estimate_mw: 2163.018066
estimate_mw: 2163.158
cpu6 {
estimate_mw: 1080.465820
estimate_mw: 1080.6881
}
cpu7 {
estimate_mw: 1082.552246
estimate_mw: 1082.47
}
}
dsu_scu {
estimate_mw: 1142.399658
estimate_mw: 1142.5181
}
}
}
Expand All @@ -431,26 +431,26 @@ def test_wattson_estimate_output(self):
metric_version: 2
period_info {
period_id: 1
period_dur: 61792614416
period_dur: 61792616758
cpu_subsystem {
estimate_mw: 42.126297
estimate_mw: 42.12355
policy0 {
estimate_mw: 34.721622
estimate_mw: 34.71888
cpu0 {
estimate_mw: 10.706565
estimate_mw: 10.7050705
}
cpu1 {
estimate_mw: 8.314949
estimate_mw: 8.315672
}
cpu2 {
estimate_mw: 7.7762628
estimate_mw: 7.7776303
}
cpu3 {
estimate_mw: 7.9238434
estimate_mw: 7.920505
}
}
dsu_scu {
estimate_mw: 7.404674
estimate_mw: 7.404673
}
}
}
Expand Down Expand Up @@ -484,26 +484,26 @@ def test_wattson_markers_rails_output(self):
metric_version: 2
period_info {
period_id: 1
period_dur: 2031870211
period_dur: 2031871358
cpu_subsystem {
estimate_mw: 46.524994
estimate_mw: 46.540943
policy0 {
estimate_mw: 34.021542
estimate_mw: 34.037483
cpu0 {
estimate_mw: 14.416650
estimate_mw: 14.416655
}
cpu1 {
estimate_mw: 6.641433
estimate_mw: 6.641429
}
cpu2 {
estimate_mw: 8.134795
estimate_mw: 8.134797
}
cpu3 {
estimate_mw: 4.828665
estimate_mw: 4.8446035
}
}
dsu_scu {
estimate_mw: 12.503452
estimate_mw: 12.503458
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
wattson_markers_threads {
metric_version: 1
task_info {
estimate_mws: 15.301090
estimate_mw: 7.530545
estimate_mws: 15.333553
estimate_mw: 7.546518
thread_name: "swapper"
thread_id: 0
process_id: 0
}
task_info {
estimate_mws: 11.805103
estimate_mw: 5.809969
estimate_mws: 11.805121
estimate_mw: 5.809974
thread_name: "RenderThread"
process_name: "com.google.android.wearable.sysui"
thread_id: 3099
process_id: 2710
}
task_info {
estimate_mws: 9.112684
estimate_mw: 4.484875
estimate_mw: 4.484872
thread_name: "binder:683_3"
process_name: "/vendor/bin/hw/vendor.qti.hardware.display.composer-service"
thread_id: 816
process_id: 683
}
task_info {
estimate_mws: 8.802605
estimate_mw: 4.332267
estimate_mws: 8.802570
estimate_mw: 4.332248
thread_name: "surfaceflinger"
process_name: "/system/bin/surfaceflinger"
thread_id: 742
process_id: 742
}
task_info {
estimate_mws: 4.008006
estimate_mw: 1.972570
estimate_mws: 4.007993
estimate_mw: 1.972562
thread_name: ".wearable.sysui"
process_name: "com.google.android.wearable.sysui"
thread_id: 2710
process_id: 2710
}
task_info {
estimate_mws: 1.779130
estimate_mw: 0.875612
estimate_mws: 1.779128
estimate_mw: 0.875610
thread_name: "crtc_commit:80"
process_name: "crtc_commit:80"
thread_id: 300
process_id: 300
}
task_info {
estimate_mws: 1.436499
estimate_mw: 0.706984
estimate_mw: 0.706983
thread_name: "binder:2710_E"
process_name: "com.google.android.wearable.sysui"
thread_id: 6515
Expand All @@ -72,8 +72,8 @@ wattson_markers_threads {
process_id: 11407
}
task_info {
estimate_mws: 1.231459
estimate_mw: 0.606072
estimate_mws: 1.231494
estimate_mw: 0.606089
thread_name: "BckgrndExec HP"
process_name: "/system/bin/surfaceflinger"
thread_id: 837
Expand Down Expand Up @@ -105,7 +105,7 @@ wattson_markers_threads {
}
task_info {
estimate_mws: 0.872391
estimate_mw: 0.429354
estimate_mw: 0.429353
thread_name: "binder:2710_7"
process_name: "com.google.android.wearable.sysui"
thread_id: 5691
Expand All @@ -129,15 +129,15 @@ wattson_markers_threads {
}
task_info {
estimate_mws: 0.795564
estimate_mw: 0.391543
estimate_mw: 0.391542
thread_name: "kgsl_dispatcher"
process_name: "kgsl_dispatcher"
thread_id: 122
process_id: 122
}
task_info {
estimate_mws: 0.716028
estimate_mw: 0.352398
estimate_mws: 0.715993
estimate_mw: 0.352381
thread_name: "irq/33-4520300."
process_name: "irq/33-4520300."
thread_id: 307
Expand All @@ -153,7 +153,7 @@ wattson_markers_threads {
}
task_info {
estimate_mws: 0.659174
estimate_mw: 0.324418
estimate_mw: 0.324417
thread_name: "surfaceflinger"
process_name: "/system/bin/surfaceflinger"
thread_id: 788
Expand Down Expand Up @@ -209,7 +209,7 @@ wattson_markers_threads {
}
task_info {
estimate_mws: 0.197450
estimate_mw: 0.097177
estimate_mw: 0.097176
thread_name: "FileWatcherThre"
process_name: "/vendor/bin/hw/android.hardware.thermal-service.pixel"
thread_id: 1544
Expand Down Expand Up @@ -257,7 +257,7 @@ wattson_markers_threads {
}
task_info {
estimate_mws: 0.095284
estimate_mw: 0.046895
estimate_mw: 0.046894
thread_name: "rcuop/2"
process_name: "rcuop/2"
thread_id: 41
Expand Down
Loading

0 comments on commit 8cd7489

Please sign in to comment.