public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/4274] New: Performance issue: pthread_cond_signal() causes three context switches instead of one
@ 2007-03-25  9:16 bart dot vanassche at gmail dot com
  2007-03-25  9:17 ` [Bug nptl/4274] " bart dot vanassche at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: bart dot vanassche at gmail dot com @ 2007-03-25  9:16 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-08-28 13:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-25  9:16 [Bug nptl/4274] New: Performance issue: pthread_cond_signal() causes three context switches instead of one bart dot vanassche at gmail dot com
2007-03-25  9:17 ` [Bug nptl/4274] " bart dot vanassche at gmail dot com
2007-03-25 11:50 ` jakub at redhat dot com
2007-03-25 14:24 ` bart dot vanassche at gmail dot com
2007-03-25 14:28 ` bart dot vanassche at gmail dot com
2007-03-28  8:18 ` jakub at redhat dot com
2007-03-30 11:35 ` jakub at redhat dot com
2007-03-30 17:06 ` bart dot vanassche at gmail dot com
2007-08-25  5:39 ` drepper at redhat dot com
2007-08-28 10:14 ` bart dot vanassche at gmail dot com
2007-08-28 12:53 ` jakub at redhat dot com
2007-08-28 13:02 ` bart dot vanassche at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).