Re: pgbench: option delaying queries till connections establishment?

Thomas Munro <thomas.munro@gmail.com>

From: Thomas Munro <thomas.munro@gmail.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Marina Polyakova <m.polyakova@postgrespro.ru>, pgsql-hackers <pgsql-hackers@postgresql.org>, kuroda.hayato@fujitsu.com, David Rowley <dgrowleyml@gmail.com>
Date: 2021-03-13T09:54:24Z
Lists: pgsql-hackers
On Sat, Mar 13, 2021 at 9:08 PM Fabien COELHO <coelho@cri.ensmp.fr> wrote:
> I must say that I'm not a big fan of the macro-based all-in-capitals API
> for threads because it exposes some platform specific uglyness (eg
> THREAD_FUNC_CC) and it does not look much like clean C code when used. I
> liked the previous partial pthread implementation better, even if it was
> not the real thing, obviously.

But we were using macros already, to support --disable-thread-safety
builds.  I just changed them to upper case and dropped the 'p',
because I didn't like to pretend to do POSIX threads, but do it so
badly.  Perhaps we should drop --disable-thread-safety soon, and
perhaps it is nearly time to create a good thread abstraction in clean
C code, for use in the server and here?  Then we won't need any ugly
macros.

> ISTM that with the current approach threads are always used on Windows,
> i.e. pgbench does not comply to "ENABLE_THREAD_SAFETY" configuration on
> that platform. Not sure whether this is an issue that need to be
> addressed, though.

The idea of that option, as I understand it, is that in ancient times
there were Unix systems with no threads (that's of course the reason
PostgreSQL is the way it is).  I don't think that was ever the case
for Windows NT, and we have no build option for that on Windows
AFAICS.



Commits

  1. Fix new pthread code to respect --disable-thread-safety.

  2. Add missing pthread_barrier_t.

  3. pgbench: Improve time logic.

  4. pgbench: Refactor thread portability support.

  5. pgbench: Synchronize client threads.

  6. Fix bogus logic for skipping unnecessary partcollation dependencies.