From owner-freebsd-current@FreeBSD.ORG Mon Mar 3 20:32:38 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B33BC1065677; Mon, 3 Mar 2008 20:32:38 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (cl-162.ewr-01.us.sixxs.net [IPv6:2001:4830:1200:a1::2]) by mx1.freebsd.org (Postfix) with ESMTP id 5AE8C8FC20; Mon, 3 Mar 2008 20:32:37 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.1/8.13.8) with ESMTP id m23KWbIm059858; Mon, 3 Mar 2008 14:32:37 -0600 (CST) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.1/8.13.8/Submit) id m23KWbIZ059857; Mon, 3 Mar 2008 14:32:37 -0600 (CST) (envelope-from brooks) Date: Mon, 3 Mar 2008 14:32:37 -0600 From: Brooks Davis To: gnn@freebsd.org Message-ID: <20080303203237.GE57043@lor.one-eyed-alien.net> References: <677e3b3e0802280915x3f29e79cqe6093b5d7bfba975@mail.gmail.com> <7ifxv7pnei.wl%gnn@neville-neil.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ILuaRSyQpoVaJ1HG" Content-Disposition: inline In-Reply-To: <7ifxv7pnei.wl%gnn@neville-neil.com> User-Agent: Mutt/1.5.16 (2007-06-09) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (lor.one-eyed-alien.net [127.0.0.1]); Mon, 03 Mar 2008 14:32:37 -0600 (CST) Cc: current@freebsd.org, jasone@freebsd.org Subject: Re: Differences in malloc between 6 and 7? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Mar 2008 20:32:38 -0000 --ILuaRSyQpoVaJ1HG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable [added jasone@ to the cc list] On Mon, Mar 03, 2008 at 03:23:33PM -0500, gnn@freebsd.org wrote: > Hi, >=20 > One of the folks I'm working with found this. The following code, > which yes, is just an example, is 1/2 as fast on 7.0-RELEASE as on > 6.3. Where should I look to find out why? All of malloc lives in src/libc/stdlib/malloc.c. I know Jason has made some changes in current so it might be worthwhile grabbing a copy from there and seeing if this case works better there. -- Brooks >=20 > Best, > George >=20 >=20 > culprit continues to be arena_run_malloc, which takes several times longer > on fbsd7 than the total of all calls to *alloc* on fbsd6. >=20 > Output of uname -a: > FreeBSD testlab5 7.0-STABLE FreeBSD 7.0-STABLE #1: Thu Feb 28 10:06:47 EST > 2008 root@builder:/usr/obj/usr/sources/FreeBSD.7/src/sys/GENERIC amd= 64 >=20 > Program source: > // simple test program that shows fbsd7 memory operations 2x slower than > fbsd6 > // compile with: > // g++ -o memory.o -c -O3 -Wall memory.cc > // g++ -o memory memory.o -O3 -L/usr/local/lib >=20 >=20 > class MemUser { > public: > void nTimesInOrder(int n) { for (int i=3D0; i freeInOrder(); } } > void alloc(); > void freeInOrder(); > void freeRandom(); >=20 > private: > char* p; > char* ptrs[16384]; > int psize; > }; >=20 > void MemUser::alloc() > { > int n =3D 0; > // for now, allocating 1000 times at each size. Sizes are 2, 20, 200, > 2000, 20k, 200k bytes > for (int size=3D2; size <=3D 2e5; size *=3D 10) { > for (int i=3D0; i<1000; ++i) { > p =3D new char [size]; > ptrs[n++] =3D p; > } > } > psize =3D n; > } >=20 > void MemUser::freeInOrder() > { > for (int i=3D0; i < psize; ++i) { > delete [] ptrs[i]; > } > } >=20 >=20 > int main(int argc, char* argv[]) > { > MemUser mu; > mu.nTimesInOrder(5000); > } >=20 >=20 > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" --ILuaRSyQpoVaJ1HG Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFHzGBkXY6L6fI4GtQRAt7rAKCBtBeel5OtaykiJZKtyp+Gqr2iAgCg11za mVXp7D2s2vWa9ofua1dVVOk= =DH+b -----END PGP SIGNATURE----- --ILuaRSyQpoVaJ1HG--