From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 30 12:15:43 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0B6ED16A41C for ; Thu, 30 Jun 2005 12:15:43 +0000 (GMT) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F9EE43D53 for ; Thu, 30 Jun 2005 12:15:42 +0000 (GMT) (envelope-from max@love2party.net) Received: from p54A3E725.dip.t-dialin.net [84.163.231.37] (helo=donor.laier.local) by mrelayeu.kundenserver.de with ESMTP (Nemesis), id 0MKwtQ-1DnxxE0804-0007xu; Thu, 30 Jun 2005 14:15:40 +0200 From: Max Laier To: freebsd-hackers@freebsd.org Date: Thu, 30 Jun 2005 14:15:31 +0200 User-Agent: KMail/1.8 References: <000d01c57cf7$b9b6f9f0$29931bd9@ertpc> In-Reply-To: <000d01c57cf7$b9b6f9f0$29931bd9@ertpc> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1192332.03hU8Kq6Lb"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200506301415.38106.max@love2party.net> X-Provags-ID: kundenserver.de abuse@kundenserver.de login:61c499deaeeba3ba5be80f48ecc83056 Cc: ant Subject: Re: hot path optimizations in uma_zalloc() & uma_zfree() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2005 12:15:43 -0000 --nextPart1192332.03hU8Kq6Lb Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday 30 June 2005 00:08, ant wrote: > I just tryed to make buckets management in perCPU cache like in > Solaris (see paper of Jeff Bonwick - Magazines and Vmem) > and got perfomance gain around 10% in my test program. > Then i made another minor code optimization and got another 10%. > The program just creates and destroys sockets in loop. > > I suppose the reason of first gain lies in increasing of cpu cache hits. > In current fbsd code allocations and freeings deal with > separate buckets. Buckets are changed when one of them > became full or empty first. In Solaris this work is pure LIFO: > i.e. alloc() and free() work with one bucket - the current bucket > (it is called magazine there), that's why cache hit rate is bigger. > > Another optimization is very trivial, for example: > - bucket->ub_cnt--; > - item =3D bucket->ub_bucket[bucket->ub_cnt]; > + item =3D bucket->ub_bucket[--bucket->ub_cnt]; > (see the patch) Might be me, but this doesn't change the generated object code at all (modu= lo=20 the changed __line__ in debugging). > the patch is for uma_core.c from RELENG_5, but i checked > uma_core.c in CURRENT - it's the same regarding to thiese > improvements. I don't have any commit rights, so the patch > is just for reviewing. Here it is: > > --- sys/vm/uma_core.c.orig Wed Jun 29 21:46:52 2005 > +++ sys/vm/uma_core.c Wed Jun 29 23:09:32 2005 > @@ -1830,8 +1830,7 @@ > > if (bucket) { > if (bucket->ub_cnt > 0) { > - bucket->ub_cnt--; > - item =3D bucket->ub_bucket[bucket->ub_cnt]; > + item =3D bucket->ub_bucket[--bucket->ub_cnt]; > #ifdef INVARIANTS > bucket->ub_bucket[bucket->ub_cnt] =3D NULL; > #endif Okay, but no effect according to my reading of the object code. > @@ -2263,8 +2262,7 @@ > if (bucket->ub_cnt < bucket->ub_entries) { > KASSERT(bucket->ub_bucket[bucket->ub_cnt] =3D=3D NULL, > ("uma_zfree: Freeing to non free bucket index.")); > - bucket->ub_bucket[bucket->ub_cnt] =3D item; > - bucket->ub_cnt++; > + bucket->ub_bucket[bucket->ub_cnt++] =3D item; This changes semantics, as far as I understand. Might be a consequence of = the=20 other work you are doing, but doesn't seem right from a first glance. =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart1192332.03hU8Kq6Lb Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (FreeBSD) iD8DBQBCw+JqXyyEoT62BG0RAr95AJ9vjKZpC3esckfOCbHaqLwJvG5VmgCeJWsY bp4IPxkZoF6bHvZ0fYJUoHc= =80+J -----END PGP SIGNATURE----- --nextPart1192332.03hU8Kq6Lb--