Thread: GCC builtins for atomic-test-and-set, memory barries, and such
Hi When reading Tom's comment about the bug in my "use latestCompletedXid to slightly speed up TransactionIdIsInProgress" patch, I remembered that I recently stumbled across GCC builtins for atomic test-and-test and read/write reordering barriers... Has anyone looked into those? It seems that those could be used to provide a fallback spinlock implementation - though maybe we already cover all interesting targets, and it's not worth the effort. Anyway, here is the link to the GCC docu. It says that the naming of these follows some Intel Spec, so presumably the Intel compiler supports the same builtins... http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html greetings, Florian Pflug
"Florian G. Pflug" <fgp@phlo.org> writes: > When reading Tom's comment about the bug in my "use latestCompletedXid > to slightly speed up TransactionIdIsInProgress" patch, I remembered that > I recently stumbled across GCC builtins for atomic test-and-test and > read/write reordering barriers... > Has anyone looked into those? It seems that those could be used to > provide a fallback spinlock implementation - though maybe we already > cover all interesting targets, and it's not worth the effort. It doesn't seem very interesting given that (a) we already have working code for this area, and (b) gcc is not our only target compiler. regards, tom lane
On 9/23/07, Tom Lane <tgl@sss.pgh.pa.us> wrote: > It doesn't seem very interesting given that (a) we already have working > code for this area, and (b) gcc is not our only target compiler. I agree. I'd prefer to know exactly what's going on in the atomic code (rather than having the compiler take care of it for me). Similarly, it's pretty rare to use GCC on anything but Linux and the *BSDs as each proprietary UNIX vendor has their own compiler optimized for their own architectures and operating systems. -- Jonah H. Harris, Sr. Software Architect | phone: 732.331.1324 EnterpriseDB Corporation | fax: 732.331.1301 499 Thornall Street, 2nd Floor | jonah.harris@enterprisedb.com Edison, NJ 08837 | http://www.enterprisedb.com/
On Mon, 24 Sep 2007, Jonah H. Harris wrote: > I agree. I'd prefer to know exactly what's going on in the atomic > code (rather than having the compiler take care of it for me). > Similarly, it's pretty rare to use GCC on anything but Linux and the > *BSDs as each proprietary UNIX vendor has their own compiler optimized > for their own architectures and operating systems. Absolutely. GCC seems to be the 'one size fits all' of compilers, meaning that it generally isn't the best at optimization for a given architecture or lacks features other, more focused compilers tend to have, like inter-procedural analysis. Derek E. Lewis dlewis at solnetworks.net http://delewis.blogspot.com