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

remove FC_USE_PTHREAD_NAME_NP & pthread_getname_np() usage #1317

Merged
merged 1 commit into from
Jun 20, 2023

Conversation

spoonincode
Copy link
Member

This refactors the thread name stuff a bit to make it simpler (have gotten bitten here a few times lately such as #1283 and #1058)

  • remove having both a set_os_thread_name() and set_thread_name() -- there is no reason setting the thread name shouldn't just set the OS thread name, having both of these (was set_thread_name() even used?) is just confusing
  • add freebsd & macos thread name support
  • remove the HAVE_PTHREAD_SETNAME_NP check; I think this was added at some point to resolve building on musl which didn't have pthread_getname_np() but while it does now,
  • remove usage of pthread_getname_np() -- just not necessary to use this instead of referring to the existing thread_local thread_name

}
#else
static int thread_count = 0;
thread_name = std::string( "thread-" ) + std::to_string( thread_count++ );
Copy link
Member

Choose a reason for hiding this comment

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

On mac we used to always get the thread-n version here. Does this now provide the actual thread name on mac?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes; really for any platform the thread names should be logged identically now since get_thread_name() just pulls from the static thread_local std::string thread_name -- that is, no platform specific code is invoked for thread names for logging purposes.

But on macos & freebsd we've also gained the thread names being set at the platform level, and I've confirmed on macos they do show in the debugger.

@spoonincode spoonincode merged commit 8afd0ae into main Jun 20, 2023
@spoonincode spoonincode deleted the remove_getthreadname branch June 20, 2023 14:34
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