From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 4 01:09:21 2005 Return-Path: X-Original-To: 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 F1D7416A41C for ; Mon, 4 Jul 2005 01:09:21 +0000 (GMT) (envelope-from ntarmos@All-Evil.ceid.upatras.gr) Received: from hermes.ceid.upatras.gr (hermes.ceid.upatras.gr [150.140.141.168]) by mx1.FreeBSD.org (Postfix) with SMTP id 1E43743D46 for ; Mon, 4 Jul 2005 01:09:20 +0000 (GMT) (envelope-from ntarmos@All-Evil.ceid.upatras.gr) Received: (qmail 21627 invoked by uid 1004); 4 Jul 2005 01:09:17 -0000 Received: from ntarmos@All-Evil.ceid.upatras.gr by hermes by uid 1001 with qmail-scanner-1.21st (clamscan: 0.70-rc. spamassassin: 2.63. Clear:RC:1(150.140.141.181):. Processed in 0.015546 secs); 04 Jul 2005 01:09:17 -0000 X-Qmail-Scanner-Mail-From: ntarmos@All-Evil.ceid.upatras.gr via hermes X-Qmail-Scanner: 1.21st (Clear:RC:1(150.140.141.181):. Processed in 0.015546 secs) Received: from diogenis.ceid.upatras.gr (150.140.141.181) by hermes.ceid.upatras.gr with SMTP; 4 Jul 2005 01:09:17 -0000 Received: (qmail 20273 invoked from network); 4 Jul 2005 01:09:15 -0000 Received: from all-evil.ceid.upatras.gr (150.140.143.230) by diogenis.ceid.upatras.gr with SMTP; 4 Jul 2005 01:09:15 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by All-Evil.ceid.upatras.gr (Postfix) with ESMTP id CCFF033C2C; Mon, 4 Jul 2005 04:09:15 +0300 (EEST) Received: from All-Evil.ceid.upatras.gr ([127.0.0.1]) by localhost (All-Evil [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 11937-01; Mon, 4 Jul 2005 04:09:08 +0300 (EEST) Received: by All-Evil.ceid.upatras.gr (Postfix, from userid 1000) id 8FEB333B38; Mon, 4 Jul 2005 04:09:08 +0300 (EEST) Date: Mon, 4 Jul 2005 04:09:08 +0300 From: Nikos Ntarmos To: Andriy Tkachuk Message-ID: <20050704010908.GA17696@diogenis.ceid.upatras.gr> References: <000d01c57cf7$b9b6f9f0$29931bd9@ertpc> <20050630163126.GA7365@diogenis.ceid.upatras.gr> <001401c57ef0$dd489720$34bf5450@ertpc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; x-action=pgp-signed Content-Disposition: inline In-Reply-To: <001401c57ef0$dd489720$34bf5450@ertpc> Organization: NetCInS Lab., C.E.I.D., U. of Patras, Greece WWW-Homepage: http://noth.ceid.upatras.gr/ X-PGP-Fingerprint: 9680 60A7 DE60 0298 B1F0 9B22 9BA2 7569 CF95 160A Office-Phone: +30-2610-996919 Office-Fax: +30-2610-969011 GPS-Info: 38.2594N, 21.7428E User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at example.com Cc: hackers@freebsd.org 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: Mon, 04 Jul 2005 01:09:22 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi there. On Sat, Jul 02, 2005 at 01:27:00PM +0300, Andriy Tkachuk wrote: > here even more refereces to memory in your variant. Ummm... What compiler version are you use? The pointer variant produces faster code for me on both NetBSD/alpha (gcc 3.3.3) and Linux/x86 (gcc 3.3.5), using both -O0 and -O2 (other compiler flags also tested with similar results). Perhaps something specific to FreeBSD then? I guess I'll have to set up a FBSD box and have a look at it, when I catch up with some of the other stuff in my todo list... Anyway, the proposed optimization even makes sense if you think about it in a logical pen-and-paper way: array variant: 1. load address of element 0 of array to register A 2. load counter to register B 3. decrease register B 4. store back new decreased B 5. load (dereference) A[B] This last operation may either translate to a leal-type instruction, or to an add+load-type sequence of instructions. pointer variant: 1. load address of pointer to register A 2. decrease register A 3. store back new decreased A 4. load (dereference) A \n\n -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Nikos "Nikolai" Ntarmos iD8DBQFCyIw0m6J1ac+VFgoRAonNAJ0Zs4Ohl+VWyv0FzgBfGV17Kt+uswCgkkRc +u9Ly5w59makY/R2noNI3nM= =ScoK -----END PGP SIGNATURE-----