Bug#238213: NPTL per char IO locking very slow
Package: libc6
Version: 2.3.2.ds1-11
Did some tests with bonnie++ on 2.6.3 with latest glibc in sid and
noticed per char IO is dreadfully slow. Remember a thread months
back about this on LKML: http://kerneltrap.org/node/view/1574
Here are the relevant benchmarks run with glibc-2.3.2.ds1-11
(using LD_ASSUME_KERNEL=2.4.1 to disable NPTL).
Version 1.03 ------Sequential Output------ --Sequential Input- --Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
2.6.3 NPTL 1G 3313 95 16808 8 5619 3 3291 93 16130 2 74.1 0
2.6.3 LxThreads 1G 11562 92 17384 8 6155 2 11370 81 15846 2 65.1 0
2.6.3 NPTL-fixed 1G 10695 78 18139 10 5399 3 12534 86 16298 3 73.7 0
Fix for this was in glibc CVS and have included a patch (tested).
~mc
#! /bin/sh -e
# All lines beginning with `# DP:' are a description of the patch.
# DP: Description: use correct version of io locking in NPTL
# DP: Related bugs:
# DP: Author: Unknown
# DP: Upstream status: In CVS
# DP: Status Details:
# DP: Date: 2004-03-16
if [ $# -ne 2 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch) patch -d "$2" -f --no-backup-if-mismatch -p0 < $0;;
-unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p0 < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
esac
exit 0
# append the patch here and adjust the -p? flag in the patch calls.
--- glibc-2.3.2/nptl/sysdeps/pthread/bits/stdio-lock.h 2003-09-01 03:07:32.000000000 +0800
+++ glibc-2.3.2/nptl/sysdeps/pthread/bits/stdio-lock.h 2003-11-05 07:43:10.000000000 +0800
@@ -29,7 +29,7 @@
typedef struct { int lock; int cnt; void *owner; } _IO_lock_t;
-#define _IO_lock_initializer { LLL_MUTEX_LOCK_INITIALIZER, 0, NULL }
+#define _IO_lock_initializer { LLL_LOCK_INITIALIZER, 0, NULL }
#define _IO_lock_init(_name) \
((_name) = (_IO_lock_t) _IO_lock_initializer , 0)
@@ -42,7 +42,7 @@
void *__self = THREAD_SELF; \
if ((_name).owner != __self) \
{ \
- lll_mutex_lock ((_name).lock); \
+ lll_lock ((_name).lock); \
(_name).owner = __self; \
} \
++(_name).cnt; \
@@ -54,7 +54,7 @@
void *__self = THREAD_SELF; \
if ((_name).owner != __self) \
{ \
- if (lll_mutex_trylock ((_name).lock) == 0) \
+ if (lll_trylock ((_name).lock) == 0) \
{ \
(_name).owner = __self; \
(_name).cnt = 1; \
@@ -72,7 +72,7 @@
if (--(_name).cnt == 0) \
{ \
(_name).owner = NULL; \
- lll_mutex_unlock ((_name).lock); \
+ lll_unlock ((_name).lock); \
} \
} while (0)
Reply to: