Skip to content

scxtop: fixing missing process names #1694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

tyroguru
Copy link
Contributor

We now have process -> thread relationships setup so the grouping are good. However, for longer running processes it is quite common for the main thread to not run at all while we are tracing and this means we never get to capture its comm. This makes it hard to identify the process to which a bunch of threads belong as any ProcessDescriptors objects which have the process_name Option unset causes the process thread (the thread group leader) to be labelled as "Process" in the resulting perfetto trace.

The solution here is to simply go lookup the comm value in /proc if it exists when scxtop exits. I'm not worried about pid reuse as trace times are too short for it to be a problem.

An example of before the changes shows the current state with lots of processes being labelled with the default label:

Screenshot 2025-04-17 at 18 42 08

Now virtually every process is labeled correctly (at least on my development machine).

Screenshot 2025-04-17 at 18 44 20

@@ -248,6 +249,12 @@ impl PerfettoTraceManager {
}
}

fn get_comm(pid: i32) -> Result<String> {
Copy link
Contributor

@hodgesds hodgesds Apr 17, 2025

Choose a reason for hiding this comment

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

nit: there's already a helper function for reading files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @hodgesds for pointing this out! I'll try and refactor some time to use that interface.

@JakeHillion JakeHillion enabled auto-merge April 17, 2025 17:59
@JakeHillion JakeHillion added this pull request to the merge queue Apr 17, 2025
Merged via the queue into sched-ext:main with commit 314cc53 Apr 17, 2025
16 checks passed
@tyroguru tyroguru deleted the processname branch April 22, 2025 10:56
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