some fixes and improvements
Andrei Nigmatulin
anight@monamour.ru
Wed, 16 Jun 2004 18:58:52 +0400
--=-n/CEoqZZEeLRE3kgmMl9
Content-Type: multipart/mixed; boundary="=-iECY7rnbneezBaJCQJHk"
--=-iECY7rnbneezBaJCQJHk
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Hello, list
I have installed memcached on linux 2.6 and have made some improvemets,
here they are:
1) mlockall(2) is priveleged function on linux, so i moved the call
before setuid().
2) i have compiled static memcached binary to have ~3GB for heap. in
order to do that i have solved two problems:
- getpwnam() uses Name Service Switching libraries internally which is
located in separate shared dlls. so when we use this functions libc does
dlopen() them and breaks our address space. so i decided to pass uid and
gid to program by numbers, and we do not need getpwnam() any more.
- malloc() always checks requested block size for some limit and in
some circumstances uses mmap() system call which is breaks address space
too. to prevent libc doing so i added option '-o', so when it specified
we call mallopt(M_MMAP_MAX, 0), so malloc will not use mmap again.
Please consider including the patches to memcached ;-)
ps sorry for bad english
--=20
Andrei Nigmatulin
GPG PUB KEY 6449830D
--=-iECY7rnbneezBaJCQJHk
Content-Disposition: attachment; filename=memcached.diff
Content-Transfer-Encoding: base64
Content-Type: text/x-patch; name=memcached.diff; charset=koi8-r
ZGlmZiAtcHJ1IG1lbWNhY2hlZC0xLjEuMTEvbWVtY2FjaGVkLmMgbWVtY2FjaGVkLTEuMS4xMS5u
ZXcvbWVtY2FjaGVkLmMNCi0tLSBtZW1jYWNoZWQtMS4xLjExL21lbWNhY2hlZC5jCTIwMDQtMDQt
MjcgMDE6MjY6NDguMDAwMDAwMDAwICswNDAwDQorKysgbWVtY2FjaGVkLTEuMS4xMS5uZXcvbWVt
Y2FjaGVkLmMJMjAwNC0wNi0xNiAxODowMTowMS4yMTUwODc4MjEgKzA0MDANCkBAIC0xMTc5LDYg
KzExNzksOCBAQCB2b2lkIHVzYWdlKHZvaWQpIHsNCiAgICAgcHJpbnRmKCItciAgICAgICAgICAg
IG1heGltaXplIGNvcmUgZmlsZSBsaW1pdFxuIik7DQ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gp-signature; name=signature.asc
Content-Description: =?koi8-r?Q?=FC=D4=C1?= =?koi8-r?Q?_=DE=C1=D3=D4=D8?=
=?koi8-r?Q?_=D3=CF=CF=C2=DD=C5=CE=C9=D1?=
=?koi8-r?Q?_=D0=CF=C4=D0=C9=D3=C1=CE=C1?=
=?koi8-r?Q?_=C3=C9=C6=D2=CF=D7=CF=CA?=
=?koi8-r?Q?_=D0=CF=C4=D0=C9=D3=D8=C0?=
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQBA0GAstpDBPmRJgw0RAm/5AJ9/As2hGfrl+IB/Uz9xfxU4XyFwHwCgo/hd
ZtTkVJoYD9GcVwS43xs2zZ0=
=gIG7
-----END PGP SIGNATURE-----
--=-n/CEoqZZEeLRE3kgmMl9--