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

Added thread pid to console log for multithread environment #54

Closed
wants to merge 2 commits into from

Conversation

bspark8
Copy link

@bspark8 bspark8 commented Feb 12, 2019

Currently, nodeos is changing from a single thread to multiple threading system.

This PR has added thread pid information to the console log for debugging and profiling in multithreading environment.

Copy link
Contributor

@heifner heifner left a comment

Choose a reason for hiding this comment

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

Is there a reason you can't use: https://en.cppreference.com/w/cpp/thread/get_id ?

@bspark8
Copy link
Author

bspark8 commented Feb 15, 2019

As you say, get_id (pthread_self) is not dependent on the OS and can be used as an uniqe identifier for each thread.
However, since get_id is an identifier of a thread used by library (POSIX thread ID), it is possible to just distinguish between threads, but it is not an OS (system) recognizable value.
that is, it is not directly mapped to the thread pid used by system tools such as linux top. (http://clanguagestuff.blogspot.com/2013/08/gettid-vs-pthreadself.html)
As mentioned above, as more threads come up, we need to know the system usage information (ex: cpu) of the threads to adjust the various setting values. It is also required for system profiling and debugging.
I would appreciate your feedback. Thank you.

@heifner
Copy link
Contributor

heifner commented Mar 24, 2019

Instead of pid we are thinking that we would rather name our threads and use that name instead of the thread-x which is currently used.

https://stackoverflow.com/questions/10121560/stdthread-naming-your-thread

If the threads were named, would that provide what you desire? Or would you still want pid logged? Note that htop will display thread names.

@bspark8
Copy link
Author

bspark8 commented Mar 26, 2019

Cool! until now, if we can distinguish between threads even if not up to pid, I think it will help profiling enough.
I will close this PR. Thank you.

@bspark8 bspark8 closed this Mar 26, 2019
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