Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VWX2W-0001Yw-O4 for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Oct 2013 19:45:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VWX2V-0004Ug-PF for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Oct 2013 19:45:51 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VWX2U-0004UV-AQ for pgsql-hackers@postgresql.org; Wed, 16 Oct 2013 19:45:50 +0000 Received: from moutng.kundenserver.de ([212.227.17.8]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VWX2Q-0007gw-Rc for pgsql-hackers@postgresql.org; Wed, 16 Oct 2013 19:45:49 +0000 Received: from anarazel.de (p54AF4158.dip0.t-ipconnect.de [84.175.65.88]) by mrelayeu.kundenserver.de (node=mrbap3) with ESMTP (Nemesis) id 0LfjPW-1W7DZ93q8I-00pJmU; Wed, 16 Oct 2013 21:45:42 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 3D6E5100B3C; Wed, 16 Oct 2013 21:45:41 +0200 (CEST) Date: Wed, 16 Oct 2013 21:45:41 +0200 From: Andres Freund To: Robert Haas Cc: Tom Lane , Peter Geoghegan , Pg Hackers , Ants Aasma Subject: Re: better atomics Message-ID: <20131016194541.GO5319@awork2.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V02:K0:I10PKyPFbn0VFKKTiqXHj4usZNBN1bw5K/hEG/Hik+m g30T+B/+Pl2na9DNtU5RaDx7WfK3vxsXY5HHU/zqjifrSl6bRB JDAdM+1T7gLwwxNoR+mqM58vN032YyxlYoDSW5BC9QyeF68lgq uFbn+2jTdtPkdNLOi6PcJ96KAhK6A8CaE82iJxE1zfPqGL9rcP GhFm7gzRDBspMO/uNPVYzowme4DuDbHtxJaA+9BXfs1OnGEko6 cWmp1y80snjP3GQoXKZoP0CfVABMCJDOsUpJnox9/lZE+8aswR rBTGpEpi6NFxtnb8AcjZWIXhwNU/Zk4eJ9nQjwZ/0Syje5Gkhb 2Uzt+I2oduIGwahi/XiPUP92vYnHZHIzOniFKtJ06 X-Pg-Spam-Score: -1.9 (-) 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 2013-10-16 14:30:34 -0400, Robert Haas wrote: > > But _and, _or are really useful because they can be used to atomically > > clear and set flag bits. > > Until we have some concrete application that requires this > functionality for adequate performance, I'd be inclined not to bother. > I think we have bigger fish to fry, and (to extend my nautical > metaphor) trying to get this working everywhere might amount to trying > to boil the ocean. Well, I actually have a very, very preliminary patch using them in the course of removing the spinlocks in PinBuffer() (via LockBufHdr()). I think it's also going to be easier to add all required atomics at once than having to go over several platforms in independent feature patches adding atomics one by one. > > I was thinking of something like: > > include/storage/atomic.h > > include/storage/atomic-gcc.h > > include/storage/atomic-msvc.h > > include/storage/atomic-acc-ia64.h > > where atomic.h first has a list of #ifdefs including the specialized > > files and then lots of #ifndef providing generic variants if not > > already provided by the platorm specific file. > Seems like we might want to put some of this in one of the various > directories called "port", or maybe a new subdirectory of one of them. Hm. I'd have to be src/include/port, right? Not sure if putting some files there will be cleaner, but I don't mind it either. > This basically sounds sane, but I'm unwilling to commit to dropping > support for all obscure platforms we currently support unless there > are about 500 people +1ing the idea, so I think we need to think about > what happens when we don't have platform support for these primitives. I think the introduction of the atomics really isn't much dependent on the removal. The only thing I'd touch around platforms in that patch is adding a generic fallback pg_atomic_test_and_set() to s_lock.h and remove the special case usages of __sync_lock_test_and_set() (Arm64, some 32 bit arms). It's the patches that would like to rely on atomics that will have the problem :( Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers