This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/4274] New: Performance issue: pthread_cond_signal() causes three context switches instead of one
- From: "bart dot vanassche at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 25 Mar 2007 09:16:30 -0000
- Subject: [Bug nptl/4274] New: Performance issue: pthread_cond_signal() causes three context switches instead of one
- Reply-to: sourceware-bugzilla at sourceware dot org
Pthread mutexes and condition variables are very often used in combination in
multithreaded software. In this combination pthread_cond_signal() is used to
wake up another thread. Optimally this wakeup would cause only one context
switch. Unfortunately pthread_cond_signal() seems to cause two context switches
on average when using linuxthreads, and three when using the NPTL.
$ uname -a
Linux pc-101 2.6.18.6 #8 Sun Feb 4 11:17:43 CET 2007 i686 athlon i386 GNU/Linux
$ /home/bart/glibc236/lib/libc.so.6
GNU C Library stable release version 2.3.6, by Roland McGrath et al.
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.1.2 20061115 (prerelease) (SUSE Linux).
Compiled on a Linux >>2.6.18.6<< system on 2007-03-17.
Available extensions:
GNU libio by Per Bothner
crypt add-on version 2.1 by Michael Glad and others
linuxthreads-0.10 by Xavier Leroy
BIND-8.2.3-T5B
libthread_db work sponsored by Alpha Processor Inc
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
$ /lib/libc.so.6
GNU C Library stable release version 2.5 (20061011), by Roland McGrath et al.
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Configured for i686-suse-linux.
Compiled by GNU CC version 4.1.2 20061115 (prerelease) (SUSE Linux).
Compiled on a Linux 2.6.18 system on 2006-11-26.
Available extensions:
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
GNU libio by Per Bothner
NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
NoVersion patch for broken glibc 2.0 binaries
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
$ LD_LIBRARY_PATH=/home/bart/glibc236/lib: /home/bart/glibc236/lib/ld-linux.so.2
./glibc236-condvar-perf
linuxthreads
mutex elapsed: 5287 us; per iteration: 52 ns / 0 context
switches.
c.v. ping-pong test elapsed: 772543 us; per iteration: 7725 ns / 4 context
switches.
signal ping-pong test elapsed: 913529 us; per iteration: 9135 ns / 4 context
switches.
$ ./condvar-perf
NPTL
mutex elapsed: 4000 us; per iteration: 40 ns / 0 context
switches.
c.v. ping-pong test elapsed: 461905 us; per iteration: 4619 ns / 6 context
switches.
signal ping-pong test elapsed: 424947 us; per iteration: 4249 ns / 4 context
switches.
--
Summary: Performance issue: pthread_cond_signal() causes three
context switches instead of one
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: nptl
AssignedTo: drepper at redhat dot com
ReportedBy: bart dot vanassche at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: i686-suse-linux-gnu
GCC host triplet: i686-suse-linux-gnu
GCC target triplet: i686-suse-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=4274
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.