diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-10 00:10:50 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-10 00:10:50 -0700 |
| commit | ac5f0ef7cf501693a9db2fcbd95b7cde419cbb2a (patch) | |
| tree | 49f479185a08e8f4b2538b3fb69ab57319a4ba60 /src/core/platform.h | |
| parent | 9feb54e9c7ab116ba566086a76604338f86e3bc3 (diff) | |
| download | nng-ac5f0ef7cf501693a9db2fcbd95b7cde419cbb2a.tar.gz nng-ac5f0ef7cf501693a9db2fcbd95b7cde419cbb2a.tar.bz2 nng-ac5f0ef7cf501693a9db2fcbd95b7cde419cbb2a.zip | |
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.
Diffstat (limited to 'src/core/platform.h')
| -rw-r--r-- | src/core/platform.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/platform.h b/src/core/platform.h index fa93916c..7acf16ef 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -1,5 +1,6 @@ // // Copyright 2017 Garrett D'Amore <garrett@damore.org> +// Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -122,6 +123,10 @@ extern void nni_plat_cv_fini(nni_plat_cv *); // called with the lock held. extern void nni_plat_cv_wake(nni_plat_cv *); +// nni_plat_cv_wake1 wakes only a single waiter. Use with caution +// to avoid losing the wakeup when multiple waiters may be present. +extern void nni_plat_cv_wake1(nni_plat_cv *); + // nni_plat_cv_wait waits for a wake up on the condition variable. The // associated lock is atomically released and reacquired upon wake up. // Callers can be spuriously woken. The associated lock must be held. |
