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 38624329E3E for ; Fri, 17 Sep 2004 20:55:08 +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 91216-08 for ; Fri, 17 Sep 2004 19:55:03 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 6DA12329D69 for ; Fri, 17 Sep 2004 20:55:01 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i8HJt0ME024166; Fri, 17 Sep 2004 15:55:00 -0400 (EDT) To: Marc Colosimo Cc: pgsql-hackers@postgresql.org Subject: Re: tweaking MemSet() performance - 7.4.5 In-reply-to: <8A6E7DA4-0654-11D9-800C-000A95A5D8B2@mitre.org> References: <8A6E7DA4-0654-11D9-800C-000A95A5D8B2@mitre.org> Comments: In-reply-to Marc Colosimo message dated "Tue, 14 Sep 2004 09:46:55 -0400" Date: Fri, 17 Sep 2004 15:55:00 -0400 Message-ID: <24165.1095450900@sss.pgh.pa.us> From: Tom Lane 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/517 X-Sequence-Number: 59083 Marc Colosimo writes: > I'm using 7.4.5 on Mac OS X (G5) and was profiling it to see why it is > SO SLOW at committing inserts and deletes into a large database. One > of the many slowdowns was from MemSet. I found an old (2002) thread > about this and retried the tests (see below). The main point is that > the system memset crushes pg's!! Hmm. I tried to duplicate this on my G4 laptop, and found that they were more or less on a par for small-to-middling block sizes (using "gcc -O2"). Darwin's memset code must have some additional tweaks for use on G5 hardware. Good for Apple --- this is the sort of thing that OS vendors *ought* to be doing. The fact that we can beat the system memset on so many platforms is an indictment of those platforms. > Is it possible to add a define to call > the system memset at build time! This probably isn't the case on other > systems. Feel free to hack the definition of MemSet in src/include/c.h. See the comments for it for more context. Note that for small compile-time-constant block sizes (a case your test program doesn't test, but it's common in pgsql), gcc with a sufficiently high optimization setting can unroll the loop into a linear sequence of words zeroings. I would expect that to beat the system memset up to a few dozen words, no matter how tense the memset coding is. So you probably want to think in terms of reducing MEMSET_LOOP_LIMIT rather than diking out the macro code altogether. Or maybe reduce MemSet to "memset(...)" but leave MemSetAligned and/or MemSetTest/MemSetLoop as-is. In any case, reporting results without mentioning the compiler and optimization level in use isn't going to convince anybody ... regards, tom lane