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

Name threads in the programs #6997

Merged
merged 10 commits into from
Oct 4, 2018
Merged

Conversation

pieterlexis
Copy link
Contributor

@pieterlexis pieterlexis commented Sep 27, 2018

Short description

This PR adds names to our progam's threads. These show up in ps -eT and in certain htop configuration. They might help users (and us) to figure out where the bottleneck in an application exists.

Closes #6974

Tested on

  • Linux
  • FreeBSD
  • Mac/Darwin
  • NetBSD
  • OpenBSD

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@pieterlexis
Copy link
Contributor Author

Reading the diff, I think a threadname.hh with a setThreadname function would help :)

@@ -34,6 +34,11 @@
void* carbonDumpThread(void*)
try
{
string threadName = "pdns/carbonDump";
auto retval = pthread_setname_np(pthread_self(), const_cast<char*>(threadName.c_str()));
Copy link
Member

Choose a reason for hiding this comment

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

By curiosity, why do you remove constness of the name argument everywhere ?

@rgacogne
Copy link
Member

Note that the _np suffix stands for non-portable, so we should probably check that the function is available during configure.

@zeha
Copy link
Collaborator

zeha commented Sep 27, 2018

Note that on BSDs, the function has a different signature:

/usr/include/pthread.h:int	pthread_setname_np(const char*);

@Habbie
Copy link
Member

Habbie commented Sep 28, 2018

Note that on BSDs, the function has a different signature:

Actually that's the Darwin signature.. the BSDs have at least two other signatures. @pieterlexis has it under control!

@ahupowerdns ahupowerdns merged commit af5b8e4 into PowerDNS:master Oct 4, 2018
@pieterlexis pieterlexis deleted the thread-names branch October 4, 2018 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants