From ac5f0ef7cf501693a9db2fcbd95b7cde419cbb2a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Thu, 10 Aug 2017 00:10:50 -0700 Subject: Thundering herd kills performance. A little benchmarking showed that we were encountering far too many wakeups, leading to severe performance degradation; we had a bunch of threads all sleeping on the same condition variable (taskqs) and this woke them all up, resulting in heavy mutex contention. Since we only need one of the threads to wake, and we don't care which one, let's just wake only one. This reduced RTT latency from about 240 us down to about 30 s. (1/8 of the former cost.) There's still a bunch of tuning to do; performance remains worse than we would like. --- src/platform/posix/posix_thread.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/platform/posix/posix_thread.c') diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c index 071e6007..0ef4754c 100644 --- a/src/platform/posix/posix_thread.c +++ b/src/platform/posix/posix_thread.c @@ -1,5 +1,6 @@ // // Copyright 2017 Garrett D'Amore +// Copyright 2017 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -116,11 +117,13 @@ nni_plat_cv_init(nni_plat_cv *cv, nni_plat_mtx *mtx) void nni_plat_cv_wake(nni_plat_cv *cv) { - int rv; + (void) pthread_cond_broadcast(&cv->cv); +} - if ((rv = pthread_cond_broadcast(&cv->cv)) != 0) { - nni_panic("pthread_cond_broadcast: %s", strerror(rv)); - } +void +nni_plat_cv_wake1(nni_plat_cv *cv) +{ + (void) pthread_cond_signal(&cv->cv); } void -- cgit v1.2.3-70-g09d2