Skip to content

Conversation

@azaleax
Copy link

@azaleax azaleax commented Nov 4, 2025

Adding CPU uptime calculation to the stdlib.

Adding a table and macro which calculates the theoretical CPU uptime cost attributed to each thread/process.
It works by assigning the "cost" (idle duration required) to enter deeper C-states (C2, C3, etc.) to the thread that kept the CPU active during that time, preventing the C-state entry.

@azaleax azaleax requested a review from a team as a code owner November 4, 2025 22:39
-- Table which groups scheduling information along with the CPU idle state
-- information. This is meant to be used in conjunciton with the android_cpu_uptime_cost
-- calculation macro.
CREATE PERFETTO TABLE android_active_sched_joined (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really don't like this table name. Please be more descriptive and consistent with the style of the stdlib instead of just calling it "joined"

-- Calculation:
-- * Uptime1 (First Process): Sched1_dur + C2_cost + C3_cost
-- * UptimeN (Subsequent Processes, N > 1): SchedN_dur
CREATE PERFETTO MACRO android_cpu_uptime_cost(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both uptime and cost are a bit vague here. Uptime means to me device uptime (i.e. time since boot). Now usually I think that word also includes time in suspend (tho I'm not 100% on that).

Can we use better words?

Copy link
Member

@LalitMaganti LalitMaganti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the

@@ -0,0 +1,195 @@
--
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this code needs tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants