Re: Fix performance of generic atomics
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Sokolov Yura <funny.falcon@postgrespro.ru>,
Simon Riggs <simon@2ndquadrant.com>, Jeff Janes <jeff.janes@gmail.com>,
Jesper Pedersen <jesper.pedersen@redhat.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2017-09-06T16:09:11Z
Lists: pgsql-hackers
On Wed, Sep 6, 2017 at 12:01 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> This seems like a pretty sound argument to me. I think Tom's probably >> right that the changes in generic-gcc.h are the important ones, but >> I'm not sure that's an argument against patching generics.h. Given >> that pg_atomic_compare_exchange_u32_impl is defined to update *old >> there seems to be no reason to call pg_atomic_read_u32_impl every time >> through the loop. > > Probably not. I'm not quite 100% convinced of that, because of my > observation that gcc is capable of generating different and better > code for some of these primitives if it can prove that the return > value is not needed. It's not clear that that could apply in any > of these uses of pg_atomic_compare_exchange_u32_impl, though. > In any case, by my own argument, it shouldn't matter, because if > any of these are really performance-critical then we should be > looking for better ways. It's not a question of whether the return value is used, but of whether the updated value of *old is used. Unless I'm confused. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Further marginal hacking on generic atomic ops.
- bfea92563c51 11.0 landed
-
Use more of gcc's __sync_fetch_and_xxx builtin functions for atomic ops.
- e09db94c0a5f 11.0 landed
-
Remove duplicate reads from the inner loops in generic atomic ops.
- e530be96859e 11.0 landed