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

Add PID and TID to the JSON output #30

Merged
merged 5 commits into from
Jun 13, 2023
Merged

Conversation

vini-fda
Copy link
Contributor

@vini-fda vini-fda commented Jun 11, 2023

For context, see issue #29.

This is my proposed solution as an attempt to write the "proper" PID and TID of the results so that the processes/threads can be differentiated.

  • The process id is retrieved using std::process::id(), which "Returns the OS-assigned process identifier associated with this process.", as documented in the Rust official docs
  • The thread id is retrieved as std::thread::current().id() , which could be problematic, as I've made a hack to convert the debug output to an int, and there's no guarantee that the integer is related to the OS's assigned identifier of the thread. A proper solution would depend on the stabilization of ThreadId::as_u64. However, as the purpose here is only to uniquely identify a thread(which is already guaranteed by the current API), I don't think this is a major issue.

Copy link
Owner

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

Thank you so much for looking into it and documenting everything so well in the issue & PR!

src/chrometrace.rs Outdated Show resolved Hide resolved
@vini-fda vini-fda requested a review from Wumpf June 12, 2023 14:56
Copy link
Owner

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

sweet. Thank you!

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.

2 participants