PATCH: pgbench - remove thread fork-emulation

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: PATCH: pgbench - remove thread fork-emulation
Date: 2015-04-27 23:18:49
Message-ID: alpine.DEB.2.10.1504271910200.13807@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


This patch removes the pgbench thread fork-emulation code and simplifies
things where possible, especially around pthread_create and pthread_join.
The stats collection for the report is done directly instead of using an
intermediate structure.

As a result, if no thread implementation is available, pgbench is
restricted to work with only the main thread (ie "pgbench -j 1 ...").

== Rational ==

Pgbench currently provides a thread emulation through process forks. This
feature was developed way back when it may have been common that some
platforms were not supporting threads. This is now very rare (can you name
one such platform?).

However, the thread fork-emulation feature has drawbacks: Namely,
processes are not threads, the memory is not shared (sure), so it hinders
simple implementation for some features, or results in not providing these
features with fork-emulation, or having a different behavior under
fork-emulation:

Latency collection (-r) is not supported with fork emulation.

Progress (-P) is reported differently with fork emulation.

For a new feature under discussion, which consist in allowing one log
instead of per-thread logs, supporting fork-emulation requires a (heavy)
post-processing external sort phase whereas with actual threads all
threads can share and append to the same log file with limited overhead,
which is significantly simpler.

== Note ==

This is a small regression (for platforms without thread support, -j J
with J > 1 is not supported anymore after the patch), so maybe this should
be included for PostgreSQL 10.0 only? I do not think this should required,
but this is only my opinion.

--
Fabien.

Attachment Content-Type Size
pgbench-threads-1.patch text/x-diff 12.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-04-27 23:21:51 Re: INSERT ... ON CONFLICT syntax issues
Previous Message Peter Geoghegan 2015-04-27 23:09:53 Re: INSERT ... ON CONFLICT syntax issues