Skip to content

Commit b183e61

Browse files
authored
stdlib: Change method to get continuous intervals for Wattson (#3406)
Use counter_leading_intervals!() to get the continuous counters instead of doing it in SQL. This is ~30-40% faster for all use cases I checked. There are some differences at the tail end of counters, but this is a negligible difference. Test: tools/diff_test_trace_processor.py out/linux_clang_release/trace_processor_shell --name-filter '.wattson' --print-slowest-tests Bug: 454944449 Signed-off-by: Samuel Wu <[email protected]>
1 parent ad4a4d5 commit b183e61

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/trace_processor/perfetto_sql/stdlib/wattson/ui/continuous_estimates.sql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
-- See the License for the specific language governing permissions and
1414
-- limitations under the License.
1515

16+
INCLUDE PERFETTO MODULE counters.intervals;
17+
1618
INCLUDE PERFETTO MODULE wattson.estimates;
1719

1820
INCLUDE PERFETTO MODULE wattson.utils;
@@ -26,21 +28,19 @@ CREATE PERFETTO MACRO _get_continuous_estimates(
2628
)
2729
RETURNS TableOrSubquery AS
2830
(
29-
WITH
30-
base AS (
31-
SELECT
32-
ts,
33-
$rail,
34-
lag($rail, 1, $rail) OVER (ORDER BY ts) != $rail AS changed
35-
FROM _system_state_mw
36-
)
3731
SELECT
3832
ts,
39-
lead(ts, 1, trace_end()) OVER (ORDER BY ts) - ts AS dur,
40-
$rail
41-
FROM base
42-
WHERE
43-
changed
33+
dur,
34+
value AS $rail
35+
FROM counter_leading_intervals!((
36+
SELECT
37+
ts,
38+
dur,
39+
$rail AS value,
40+
NULL AS id,
41+
NULL AS track_id
42+
FROM _system_state_mw
43+
))
4444
);
4545

4646
CREATE PERFETTO TABLE _system_state_cpu0_mw AS

test/trace_processor/diff_tests/metrics/android/wattson_trace_threads.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ wattson_trace_threads {
55
period_info {
66
period_id: 1
77
task_info {
8-
estimated_mws: 34.415909
9-
estimated_mw: 3.961489
8+
estimated_mws: 34.41899
9+
estimated_mw: 3.961843
1010
idle_transitions_mws: -20.19533
11-
total_mws: 14.220581
11+
total_mws: 14.22366
1212
thread_name: "swapper"
1313
process_name: ""
1414
thread_id: 0
@@ -1335,10 +1335,10 @@ wattson_trace_threads {
13351335
process_id: 1926
13361336
}
13371337
task_info {
1338-
estimated_mws: 0.257572
1339-
estimated_mw: 0.029648
1338+
estimated_mws: 0.259248
1339+
estimated_mw: 0.029841
13401340
idle_transitions_mws: 0.187774
1341-
total_mws: 0.445345
1341+
total_mws: 0.447021
13421342
thread_name: "kworker/3:5"
13431343
process_name: "kworker/3:5"
13441344
thread_id: 104

0 commit comments

Comments
 (0)