Fix for redundant thread contention in CsdNextMessage#3916
Merged
ericjbohm merged 2 commits intocharmplusplus:mainfrom Jan 12, 2026
Merged
Fix for redundant thread contention in CsdNextMessage#3916ericjbohm merged 2 commits intocharmplusplus:mainfrom
ericjbohm merged 2 commits intocharmplusplus:mainfrom
Conversation
Collaborator
|
I had also noticed a lot of time spend in locking the Node Queue. I implemented a similar fix: index 9581f234f..718bb9cc0 100644
--- a/src/conv-core/convcore.C
+++ b/src/conv-core/convcore.C
@@ -1766,7 +1766,7 @@ void *CsdNextMessage(CsdSchedulerState_t *s) {
/*#warning "CsdNextMessage: CMK_NODE_QUEUE_AVAILABLE" */
if (NULL!=(msg=CmiGetNonLocalNodeQ())) return msg;
#if !CMK_NO_MSG_PRIOS
- if(CmiTryLock(s->nodeLock) == 0) {
+ if(!CqsEmpty(s->nodeQ) && (CmiTryLock(s->nodeLock) == 0)) {
if (!CqsEmpty(s->nodeQ)
&& CqsPrioGT(CqsGetPriority(s->schedQ),
CqsGetPriority(s->nodeQ))) {but I never got around to benchmarking the change. Neverless I think this is a good idea for machines with a high core count. |
Contributor
Author
yeah, I had also started with one-line fix but then decided to add one more basic block to make the commentary more understandable. |
ericjbohm
approved these changes
Jan 6, 2026
ritvikrao
approved these changes
Jan 6, 2026
Contributor
Author
|
Thank you for approving changes! But I do not see "merge" button, is this because of CI stall on darwin? Or it will be manually merged by reviewers? |
Contributor
|
We're working through a fix to the CI issue with darwin. When we have that
in place, I'll rebase your change to get it merged.
…On Wed, Jan 7, 2026 at 11:21 AM Vladimir Polin ***@***.***> wrote:
*vladimir-polin* left a comment (charmplusplus/charm#3916)
<#3916 (comment)>
Thank you for approving changes! But I do not see "merge" button, is this
because of CI stall on darwin? Or it will be manually merged by reviewers?
—
Reply to this email directly, view it on GitHub
<#3916 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3HFH35NQO4PRHSXHH4DJL4FU6CFAVCNFSM6AAAAACP5CKIBSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTOMJZHEYTONJQGE>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
Contributor
Author
|
So nothing is needed from my side yet, thanks for letting me know. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for redundant thread contention in CsdNextMessage (CmiTryLock/pthread_mutex_trylock) for node-level threading parallelism with high number of threads.
Instead of simple try_lock call this patch checks lock-free first that the queue is not empty and if it is not empty then there is try_lock and the queue is checked again inside the critical section to avoid a potential data race.