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
Member

@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 added 5 commits Sep 27, 2018
@pieterlexis
Copy link
Member Author

@pieterlexis pieterlexis commented Sep 27, 2018

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()));

This comment has been minimized.

@chbruyand

chbruyand Sep 27, 2018
Member

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

@rgacogne
Copy link
Member

@rgacogne rgacogne commented Sep 27, 2018

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 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*);
pieterlexis added 2 commits Sep 27, 2018
@Habbie
Copy link
Member

@Habbie 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!

pieterlexis added 3 commits Sep 28, 2018
@pieterlexis pieterlexis force-pushed the pieterlexis:thread-names branch from a1efda8 to f4703d4 Sep 28, 2018
@ahupowerdns ahupowerdns merged commit af5b8e4 into PowerDNS:master Oct 4, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@pieterlexis pieterlexis deleted the pieterlexis:thread-names branch Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.