Repository navigation
build, util: name OpenBSD threads - #399
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste |
hebasto
left a comment
There was a problem hiding this comment.
Concept ACK.
A few notes not strictly related to this PR's changes:
-
The current CI logs are not really helpful when tests could be skipped at compile time or at runtime. We could improve this. For example, we could either make the
ctestoutput verbose or split the test binaries and letctestmanage them. -
The config macros set via
#cmakedefine FOO ...are susceptible to misspelled macro names in the code going undetected (see bitcoin/bitcoin#36874).
| #include <pthread_np.h> | ||
| int main() | ||
| { | ||
| char thread_name[16]; |
There was a problem hiding this comment.
Because ThreadName uses char[16] and this also matches HAVE_PTHREAD_GETNAME_NP
| #elif defined(HAVE_PTHREAD_GETTHREADID_NP) | ||
| pthread_set_name_np(pthread_self(), name); // FreeBSD | ||
| #elif defined(HAVE_PTHREAD_SET_NAME_NP) | ||
| pthread_set_name_np(pthread_self(), name); // FreeBSD, OpenBSD, DragonFly |
There was a problem hiding this comment.
Has someone tested this code on DragonFly?
There was a problem hiding this comment.
Idk anyone who has tried this with Dragonfly. I added Dragonfly comment because it is one of the platform that Bitcoin Core checks to use pthread_set_name_np
| #cmakedefine HAVE_PTHREAD_SET_NAME_NP @HAVE_PTHREAD_SET_NAME_NP@ | ||
| #cmakedefine HAVE_PTHREAD_GET_NAME_NP @HAVE_PTHREAD_GET_NAME_NP@ |
There was a problem hiding this comment.
I understand that these lines follow the already used pattern, but this would suffice:
| #cmakedefine HAVE_PTHREAD_SET_NAME_NP @HAVE_PTHREAD_SET_NAME_NP@ | |
| #cmakedefine HAVE_PTHREAD_GET_NAME_NP @HAVE_PTHREAD_GET_NAME_NP@ | |
| #cmakedefine HAVE_PTHREAD_SET_NAME_NP 1 | |
| #cmakedefine HAVE_PTHREAD_GET_NAME_NP 1 |
There was a problem hiding this comment.
Cool, do you think it would be better to replace all of those with 1?
| } | ||
|
|
||
| #ifdef HAVE_PTHREAD_GETNAME_NP | ||
| #if defined(HAVE_PTHREAD_GETNAME_NP) || defined(HAVE_PTHREAD_GET_NAME_NP) |
There was a problem hiding this comment.
While touching this line, it would be great to add an explanatory comment based on @ryanofsky's reasoning here.
a67dd36 to
a5e5585
Compare
|
Thanks @xyzconstant and @hebasto for reviewing! Force-pushed a5e5585 addressing #399 (comment) |
|
|
||
| } // namespace | ||
|
|
||
| // Copied from https://github.com/bitcoin/bitcoin/blob/d3e40af2597/src/util/threadnames.cpp#L21-L36 |
There was a problem hiding this comment.
just an observation while reviewing this.
are there intentions to align this code for both codebases since they have grown out of sync ?
in bitcoin/bitcoin there is no NetBSD or illumos support (i had plans to work on NetBSD but got occupied elsewhere), whereas it is covered here. conversely, bitcoin/bitcoin supports Windows but it is absent here
might be a good idea for a follow-up
There was a problem hiding this comment.
I think it is good to keep them in sync when they share the same platform.
libmultiprocess doens't support Windows yet and illumos is not oficially supported by Bitcoin Core. NetBSD is the only outlier that Bitcoin Core oficially suports but don't name threads.
Add
HAVE_PTHREAD_SET_NAME_NPandHAVE_PTHREAD_GET_NAME_NPmacros to support OpenBSD thread names and also address #324 (comment)