X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C893132A18A for ; Wed, 29 Sep 2004 09:48:32 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42472-04 for ; Wed, 29 Sep 2004 08:48:25 +0000 (GMT) Received: from marvin.jcu.cz (marvin.jcu.cz [160.217.1.3]) by svr1.postgresql.org (Postfix) with ESMTP id D148132A16D for ; Wed, 29 Sep 2004 09:48:18 +0100 (BST) Received: from marvin.jcu.cz (localhost.localdomain [127.0.0.1]) by nod32.jcu.cz (Postfix) with ESMTP id 8B5DC8FBDD; Wed, 29 Sep 2004 10:48:08 +0200 (CEST) X-Virus-Scanner: This message was checked by NOD32 Antivirus system NOD32 for Linux Mail Server. For more information on NOD32 Antivirus System, please, visit our website: http://www.nod32.com/. Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) by marvin.jcu.cz (Postfix) with ESMTP id A327E8FBEC; Wed, 29 Sep 2004 10:48:07 +0200 (CEST) Subject: Re: tweaking MemSet() performance - 7.4.5 From: Karel Zak To: Manfred Spraul Cc: mcolosimo@smtp-bedford.mitre.org, Marc Colosimo , List pgsql-hackers In-Reply-To: <4155E1C1.4030503@colorfullife.com> References: <22741566.1095718812574.JavaMail.ipsadmin@emiisrv> <4155E1C1.4030503@colorfullife.com> Content-Type: text/plain Date: Wed, 29 Sep 2004 10:46:18 +0200 Message-Id: <1096447578.2705.6.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 1.5.94.1 (1.5.94.1-1) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/875 X-Sequence-Number: 59441 On Sat, 2004-09-25 at 23:23 +0200, Manfred Spraul wrote: > mcolosimo@mitre.org wrote: > > >>If the memset > >>bypasses the cache then the following access will cause a cache line > >>miss, which can be so slow that using the faster memset can result in a > >>net performance loss. > >> > >> > >> > > > >Could you suggest some structs to test? If I get your meaning, I would make a loop that sets then reads from the structure. > > > > > > > Read the sources and the cpu specs. Benchmarking such problems is > virtually impossible. > I don't have OS-X, thus I checked the Linux-kernel sources: It seems > that the power architecture doesn't have the same problem as x86. > There is a special clear cacheline instruction for large memsets and the > rest is done through carefully optimized store byte/halfword/word/double > word sequences. > > Thus I'd check what happens if you memset not perfectly aligned buffers. > That's another point where over-optimized functions sometimes break > down. If there is no slowdown, then I'd replace the postgres function > with the OS provided function. > > I'd add some __builtin_constant_p() optimizations, but I guess Tom won't > like gcc hacks ;-) I think it cannot be problem if you write it to some .h file (in port directory?) as macro with "#ifdef GCC". The other thing is real advantage of hacks like this in practical PG usage :-) Karel -- Karel Zak http://home.zf.jcu.cz/~zakkr