google / google/perfetto

Multi-machine migration broke battery counters

Open
#7,302 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
6.5k
Forks
868
Avg merge
2d 1h
Merged PRs (30d)
218

Description

The migration in #7243 is causing battery counters such as the charging state to break:

Image

I'm working on a quick fix, but this whole area is quite fragile so want to use this to discuss a better long term plan.

The change in #7243 sensibly tries to use `counter_leading_intervals` partitioned by `track_id`. The issue is that many of the battery related counters are populated by two data sources and and up in two tracks:
1. We get them from regular atrace.
2. We poll them using the `android.system_property` datasource. This is primarily to populate the start state, but is often configured to still poll multiple times per trace.

Because they're in two tracks, we end up with two concurrent spans like the picture above, even on a single-machine trace. The quick fix is to change `counter.track_id` to `counter.machine_id AS track_id` (and downstream) so that counter leading intervals partitions only by machine.

@LalitMaganti: do you have any ideas on how to make this less fragile? The [importer here](https://github.com/google/perfetto/blob/56b3c449c968296bda3831d7cd2e0d2140acc9e9/src/trace_processor/importers/proto/android_probes_parser.cc#L670) can't know which process is going to emit the atrace. We _could_ have the atrace importer find the same events and emit it using the same track blueprint, but that doesn't seem great.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing migration #7243 and the counter_leading_intervals change, then inspect src/trace_processor/importers/proto/android_probes_parser.cc around line 670. Reproduce the single-machine case where atrace and android.system_property populate the same battery counters, and compare the quick fix with a less fragile long-term approach. Done means battery counters no longer produce concurrent duplicate spans and leading intervals partition correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
data, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.