Skip to content
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

Cannot control thread order in perfetto #555

Closed
bartosz-lew-int opened this issue Aug 11, 2023 · 3 comments
Closed

Cannot control thread order in perfetto #555

bartosz-lew-int opened this issue Aug 11, 2023 · 3 comments

Comments

@bartosz-lew-int
Copy link

bartosz-lew-int commented Aug 11, 2023

With the following trace event file:

{"traceEvents":[
{"name": "process_name", "ph": "M", "pid":0, "args": {"name" : "Process (0)"}},
{"name": "process_sort_index", "ph": "M", "pid":0, "args": {"sort_index" : "0"}},
{"name": "thread_name", "ph": "M", "pid":0, "tid":0, "args": {"name" : "th1"}},
{"name": "thread_name", "ph": "M", "pid":0, "tid":1, "args": {"name" : "th2"}},
{"name": "process_name", "ph": "M", "pid":1, "args": {"name" : "Process (1)"}},
{"name": "process_sort_index", "ph": "M", "pid":1, "args": {"sort_index" : "1"}},
{"name": "thread_name", "ph": "M", "pid":1, "tid":0, "args": {"name" : "th1"}},
{"name": "thread_name", "ph": "M", "pid":1, "tid":1, "args": {"name" : "th2"}},
{"name":"A", "cat":"X", "ph":"X", "ts":1, "dur":3, "pid":0, "tid":0},
{"name":"B", "cat":"Y", "ph":"X", "ts":2, "dur":2, "pid":0, "tid":1},
{"name":"A", "cat":"X", "ph":"X", "ts":1, "dur":3, "pid":1, "tid":0},
{"name":"B", "cat":"Y", "ph":"X", "ts":2, "dur":2, "pid":1, "tid":1}
]
}

one obtains the following report

image

where thread order in the first process follows thread id (or thread name lexicographic ordering) but the second process that contains exactly the same data shows threads in different order.

The expected result would be to have both threads in the same order.

using version: v35.0-8019b from
https://ui.perfetto.dev/

@LalitMaganti
Copy link
Collaborator

This is working as intended: we very intentionally do not support process_sort_index as we made a conscious choice to separate trace rendering from the trace contents. See also our policy on JSON traces here.

Improving options for visualising only the parts of the trace which matter to the user is something which is being worked on right now and is tracked by #429

@bartosz-lew-int
Copy link
Author

bartosz-lew-int commented Aug 11, 2023

Thanks for the answer and tips. However the main point was about having some rules that would help to understand the ordering in which threads are being displayed (not processes). I'd appreciate to know if there is some workaround for this to have the above threads presented in the report in the consistent order i.e.

process 0
th1
th2

process 1
th1 (rather than th2)
th2 (rather than th1)

Thanks again.
ps. Indeed the report looks fine in the Legacy UI.

@LalitMaganti
Copy link
Collaborator

I'd appreciate to know if there is some workaround for this to have the above threads presented in the report in the consistent order i.e.

There are no workarounds I'm afraid. The order of the tracks is determined by the "activity" of the process (think the amount of time that a slice is active across all the threads). This is hardcoded into the UI and there's no way to change this at the moment.

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

No branches or pull requests

2 participants