This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/4274] Performance issue: pthread_cond_signal() causes three context switches instead of one


------- Additional Comments From bart dot vanassche at gmail dot com  2007-03-30 18:06 -------
(In reply to comment #6)
> Can you strace -f it?  If it doesn't use futex (..., 0x5, ...) (aka
> FUTEX_WAKE_OP), then it is just a badly built glibc or your kernel is missing
> that functionality.

After adding an fflush(stdout) just before the end of run_test I get the
following (this test is done with openSUSE's glibc-2.5-25):

$ strace -f ./condvar-perf 222 2>&1 | less
...
clock_gettime(CLOCK_MONOTONIC, {832, 851599805}) = 0
clock_gettime(CLOCK_MONOTONIC, {832, 851627494}) = 0
...
write(1, "NPTL\nmutex                   ela"..., 85NPTL
mutex                   elapsed:       28 us; per iteration:  126 ns / 0.11 csw
) = 85
...
[pid  6781] futex(0xbfb95840, FUTEX_WAIT, 2, NULL <unfinished ...>
[pid  6783] futex(0xbfb95840, FUTEX_WAKE, 1 <unfinished ...>
[pid  6781] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavai
lable)
[pid  6783] <... futex resumed> )       = 0
[pid  6781] futex(0xbfb95858, FUTEX_WAIT, 2, NULL <unfinished ...>
[pid  6783] futex(0xbfb95858, FUTEX_WAKE, 1 <unfinished ...>
[pid  6781] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavai
lable)
[pid  6783] <... futex resumed> )       = 0
[pid  6781] futex(0xbfb9585c, 0x5 /* FUTEX_??? */, 1 <unfinished ...>
[pid  6783] futex(0xbfb9585c, FUTEX_WAIT, 871, NULL <unfinished ...>
[pid  6781] <... futex resumed> )       = 0
[pid  6783] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavai
lable)
[pid  6781] futex(0xbfb95840, FUTEX_WAKE, 1 <unfinished ...>
[pid  6783] futex(0xbfb95858, FUTEX_WAIT, 2, NULL <unfinished ...>
[pid  6781] <... futex resumed> )       = 0
[pid  6781] futex(0xbfb95858, FUTEX_WAKE, 1 <unfinished ...>
[pid  6783] <... futex resumed> )       = 0
[pid  6781] <... futex resumed> )       = 1
...
write(1, "c.v. ping-pong test     elapsed:"..., 88c.v. ping-pong test     elapse
d: 82901328 us; per iteration: 373429405 ns / 3.8e+02 csw
) = 88
...[pid  6796] rt_sigtimedwait([ALRM],  <unfinished ...>
[pid  6781] rt_sigtimedwait([ALRM],  <unfinished ...>
[pid  6796] <... rt_sigtimedwait resumed> 0, 0, 8) = 14
[pid  6796] tgkill(6781, 6781, SIGALRM <unfinished ...>
[pid  6781] <... rt_sigtimedwait resumed> 0, 0, 8) = 14
[pid  6796] <... tgkill resumed> )      = 0
[pid  6781] futex(0xbfb9586c, FUTEX_WAIT, 2, NULL <unfinished ...>
[pid  6796] futex(0xbfb9586c, FUTEX_WAKE, 1 <unfinished ...>
[pid  6781] <... futex resumed> )       = -1 EAGAIN (Resource temporarily unavai
lable)
[pid  6796] <... futex resumed> )       = 0
[pid  6781] tgkill(6781, 6796, SIGALRM <unfinished ...>
...
write(1, "signal ping-pong test   elapsed:"..., 89signal ping-pong test   elapse
d: 116494476 us; per iteration: 524749891 ns / 5.5e+02 csw
) = 89
...
[pid  6781] rt_sigtimedwait([ALRM],  <unfinished ...>
[pid  7207] rt_sigtimedwait([ALRM],  <unfinished ...>
[pid  6781] <... rt_sigtimedwait resumed> 0, 0, 8) = 14
[pid  7207] <... rt_sigtimedwait resumed> 0, 0, 8) = 14
[pid  6781] tgkill(6781, 7207, SIGALRM <unfinished ...>
[pid  7207] tgkill(6781, 6781, SIGALRM <unfinished ...>
[pid  6781] <... tgkill resumed> )      = 0
[pid  7207] <... tgkill resumed> )      = 0
...
write(1, "signal ping-pong no mtx elapsed:"..., 90signal ping-pong no mtx elapse
d: 503406198 us; per iteration: 2267595486 ns / 1.6e+03 csw
) = 90
exit_group(0)                           = ?
Process 6781 detached


Similar result with glibc built from CVS sources:

$ strace -f bash -c 'LD_LIBRARY_PATH=/home/bart/glibc-cvs/lib:
/home/bart/glibc-cvs/lib/ld-linux.so.2 ./glibc-cvs-condvar-perf 2' 2>&1|grep
'FUTEX_???'
[pid  7467] futex(0xbfea12fc, 0x5 /* FUTEX_??? */, 1 <unfinished ...>
[pid  7465] futex(0xbfea12fc, 0x5 /* FUTEX_??? */, 1) = 0
[pid  7467] futex(0xbfea12fc, 0x5 /* FUTEX_??? */, 1 <unfinished ...>
[pid  7465] futex(0xbfea12fc, 0x5 /* FUTEX_??? */, 1) = 0


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]