Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4YIh-0005IM-CZ for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Oct 2017 20:17:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e4YIg-0003s4-8u for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Oct 2017 20:17:18 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e4YIf-0003rv-IT for pgsql-hackers@postgresql.org; Tue, 17 Oct 2017 20:17:17 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e4YIb-00030V-HP for pgsql-hackers@postgresql.org; Tue, 17 Oct 2017 20:17:16 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 5266320E4D; Tue, 17 Oct 2017 16:17:12 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Tue, 17 Oct 2017 16:17:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=wUggOjy2rd/CMLtd3dC72ouwRWuAC jRuBfX83rM0vws=; b=Z10ncMxttJJ+zLQZBbRp0M5ktqGGy8FN3rZykPeI1u8o0 L4Zv+jMi5P3rBJJFERW6pExgt4F8lEYlURt8R6VbvvHNf/Q3A5jXJAcaU7fzzA3s VIRE0iaC+/WDF9pVSR0Bp4EQdFRC1Mnn9p+95/F2raPh6AHsM5Ph//VHh14aUZN6 JT+cp2Gd71l+3kQusg1aGOtEEqPnGkMOrF8izZr6W6Lqh1tQfdfjsrKXfyBUmjR8 uVcDvwLy2Xu94cg/WeZ2YYiylqm6wVBnj4Fgd18/itOsYJ1lfqnS3iCf8gfVZVut ITIohCBaiWoVoj83efcJajAMrbl3HBgp84U1eKpBw== X-ME-Sender: Received: from intern.anarazel.de (unknown [136.24.76.72]) by mail.messagingengine.com (Postfix) with ESMTPA id F077E7FA7D; Tue, 17 Oct 2017 16:17:11 -0400 (EDT) Date: Tue, 17 Oct 2017 13:17:10 -0700 From: Andres Freund To: Tom Lane Cc: Andrew Dunstan , Haribabu Kommi , PostgreSQL-development Subject: Re: Windows warnings from VS 2017 Message-ID: <20171017201710.xsgresmef7brwwik@alap3.anarazel.de> References: <8649.1505951694@sss.pgh.pa.us> <7214.1506000631@sss.pgh.pa.us> <20170922014108.64om7wh3ozfhcczl@alap3.anarazel.de> <20171011212816.vbpff7jkolna6kbm@alap3.anarazel.de> <5100.1507760424@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5100.1507760424@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2017-10-11 18:20:24 -0400, Tom Lane wrote: > Well, it's not that much work to try it and see. I compared results > of this simplistic test case: > pgbench -S -c 1 -T 60 bench > (using a scale-factor-10 pgbench database) on current HEAD and HEAD > with the attached patch, which just lobotomizes all the MemSet > macros into memset(). Median of 3 runs is 9698 tps for HEAD and > 9675 tps with the patch; the range is ~100 tps though, making > this difference well within the noise level. > > I did this using RHEL6's gcc (Red Hat 4.4.7-18), which is pretty > far from bleeding-edge so I think it's okay as a baseline for > what optimizations we can expect to find used in the field. > > So I can't sustain Andres' assertion that memset is actually faster > for the cases we care about, but it certainly doesn't seem any > slower either. It would be interesting to check compromise > patches, such as keeping only the MemSetLoop case. Well, that'd be because that workload doesn't exercise either version of memset to a meaningful degree, right? > +#define MemSetAligned(start, val, len) memset(start, val, len) If we actually care about this optimization, which seems to solely serve palloc0fast, we could tell the compiler about the guaranteed alignment etc. I'm doubtful it's worth making this work for palloc0fast alone, but I think it might be worthwhile to make palloc0 an inline function like #ifdef YES_I_AM_A_GOOD_COMPILER /* not needed here, but probably good for plenty other places */ #define pg_attribute_assume_aligned(align) __attribute__((assume_aligned(align))) #define pg_assume_aligned(ptr, align) __builtin_assume_aligned(ptr, align) #else ... #end extern void *palloc(Size size) pg_attribute_assume_aligned(MAXALIGN); static inline void * palloc0(Size size) { void *mem = palloc(size); memset(mem, 0, size); return mem; } that should allow the compiler to always optimize the memset based on the alignment - at least x86 gcc does so - and on the size if a built-time constant (nearly every compiler does so). I assume we probably should do this dance not just for palloc, but for the other allocation functions too. Greetings, Andres Freund -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers