Re: better atomics - v0.6
Andres Freund <andres@2ndquadrant.com>
From: Andres Freund <andres@2ndquadrant.com>
To: Oskari Saarenmaa <os@ohmu.fi>
Cc: Robert Haas <robertmhaas@gmail.com>,
Amit Kapila <amit.kapila16@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>,
Peter Geoghegan <pg@heroku.com>, Pg Hackers <pgsql-hackers@postgresql.org>,
Ants Aasma <ants@cybertec.at>
Date: 2014-09-23T22:11:48Z
Lists: pgsql-hackers
On 2014-09-24 00:27:25 +0300, Oskari Saarenmaa wrote: > 23.09.2014, 15:18, Andres Freund kirjoitti: > >On 2014-09-23 13:50:28 +0300, Oskari Saarenmaa wrote: > >>23.09.2014, 00:01, Andres Freund kirjoitti: > >>>The patches: > >>>0001: The actual atomics API > >> > >>I tried building PG on Solaris 10/Sparc using GCC 4.9.0 (buildfarm animal > >>dingo) with this patch but regression tests failed due to: > > > >Btw, if you could try sun studio it'd be great. I wrote the support for > >it blindly, and I'd be surprised if I got it right on the first try. > > I just installed Solaris Studio 12.3 and tried compiling this: Cool. > "../../../../src/include/port/atomics/generic-sunpro.h", line 54: return > value type mismatch > "../../../../src/include/port/atomics/generic-sunpro.h", line 77: return > value type mismatch > "../../../../src/include/port/atomics/generic-sunpro.h", line 79: #if-less > #endif > "../../../../src/include/port/atomics/generic-sunpro.h", line 81: #if-less > #endif > > atomic_add_64 and atomic_add_32 don't return anything (the atomic_add_*_nv > variants return the new value) and there were a few extra #endifs. > Regression tests pass after applying the attached patch which defines > PG_HAS_ATOMIC_ADD_FETCH_U32. Thanks for the fixes! Hm. I think then it's better to simply not implement addition and rely on cmpxchg. > Also, it's not possible to compile PG with FORCE_ATOMICS_BASED_SPINLOCKS > with these patches: > > "../../../../src/include/storage/s_lock.h", line 868: #error: PostgreSQL > does not have native spinlock support on this platform.... > > atomics/generic.h would implement atomic flags using operations exposed by > atomics/generic-sunpro.h, but atomics/fallback.h is included before it and > it defines functions for flag operations which s_lock.h doesn't want to use. Right. It should check not just for flag support, but also for 32bit atomics. Easily fixable. I'll send a new version with your fixes incorporated tomorrow. Thanks for looking into this! Very helpful. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Commits
-
Avoid the use of a separate spinlock to protect a LWLock's wait queue.
- 008608b9d510 9.6.0 cited
-
Improve LWLock scalability.
- ab5194e6f617 9.5.0 cited
-
Reduce the number of semaphores used under --disable-spinlocks.
- daa7527afc22 9.4.0 cited
-
Alter the configure script to fail immediately if the C compiler does not
- d15cb38dec01 9.0.0 cited