Skip to content

[Bug/Enhancement] Sched plugin aggregates CPU slices by process_name, not PID, impacting analysis (v54) #5227

@wenyongli1122

Description

@wenyongli1122

Hello!

I've been using Perfetto for trace analysis recently and it's a fantastic tool. While exploring the UI, I've noticed an aggregation behavior in the cpu_slice_by_process_selection_aggregator.ts plugin that I believe could be improved for more precise analysis.

It looks like the plugin, specifically observed in v54, aggregates CPU slices based solely on process_name. This can be problematic, especially when dealing with systrace data where multiple processes might share the same name but have distinct Process IDs (PIDs). For example, if you have several instances of a shell or a service that forks child processes with similar names, all their CPU slices get grouped together under one process_name entry.

This aggregation method leads to several issues:

  • Misleading Data: Users might misinterpret aggregated data as representing a single process, when in reality it's a mix of several.
  • Difficulty in Debugging: It becomes challenging to pinpoint performance issues or resource consumption for a specific process instance when its data is merged with others.
  • Reduced Granularity: The inability to analyze by PID reduces the granularity and effectiveness of the Sched plugin for certain complex tracing scenarios.

My initial thought is that for more precise and meaningful analysis, the CPU slice aggregation should ideally consider process_pid in addition to (or as the primary key for) process_name. This would allow users to differentiate between distinct process instances even if they share the same name.

I haven't delved deep into the UI's plugin architecture yet, but I imagine a solution could involve:

  • Prioritizing process_pid for aggregation, perhaps by creating a unique key like ${process_name} [${process_pid}].
  • Providing an option in the UI to switch between process_name and process_pid based aggregation.
  • By default, aggregating by process_name but allowing expanding to show individual process_pid entries.

If this is something other folks are interested in or if there's a current workaround I'm missing, I'd be happy to give it a shot at exploring potential solutions or contributing. Wanted to put feelers out before typing up a full proposal.

Thank you for your time and consideration!

Location of the issue:
ui/src/plugins/dev.perfetto.Sched/cpu_slice_by_process_selection_aggregator.ts

Version Affected:
Perfetto UI v54 (and potentially earlier/later versions if the logic hasn't changed).

Steps to Reproduce (Conceptual):

  1. Record a systrace or any trace where multiple processes have the same process_name but different PIDs (e.g., multiple instances of a shell, or a service that forks child processes with similar names).
  2. Load the recorded trace in Perfetto UI v54.
  3. Navigate to the Sched slice table or any view that utilizes the cpu_slice_by_process_selection_aggregator.
  4. Observe that CPU slices belonging to different PIDs but the same process_name are grouped together, without an option to distinguish by PID.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions