postgresql/src/include
Andres Freund 98a64d0bd7 Introduce WaitEventSet API.
Commit ac1d794 ("Make idle backends exit if the postmaster dies.")
introduced a regression on, at least, large linux systems. Constantly
adding the same postmaster_alive_fds to the OSs internal datastructures
for implementing poll/select can cause significant contention; leading
to a performance regression of nearly 3x in one example.

This can be avoided by using e.g. linux' epoll, which avoids having to
add/remove file descriptors to the wait datastructures at a high rate.
Unfortunately the current latch interface makes it hard to allocate any
persistent per-backend resources.

Replace, with a backward compatibility layer, WaitLatchOrSocket with a
new WaitEventSet API. Users can allocate such a Set across multiple
calls, and add more than one file-descriptor to wait on. The latter has
been added because there's upcoming postgres features where that will be
helpful.

In addition to the previously existing poll(2), select(2),
WaitForMultipleObjects() implementations also provide an epoll_wait(2)
based implementation to address the aforementioned performance
problem. Epoll is only available on linux, but that is the most likely
OS for machines large enough (four sockets) to reproduce the problem.

To actually address the aforementioned regression, create and use a
long-lived WaitEventSet for FE/BE communication.  There are additional
places that would benefit from a long-lived set, but that's a task for
another day.

Thanks to Amit Kapila, who helped make the windows code I blindly wrote
actually work.

Reported-By: Dmitry Vasilyev Discussion:
CAB-SwXZh44_2ybvS5Z67p_CDz=XFn4hNAD=CnMEF+QqkXwFrGg@mail.gmail.com
20160114143931.GG10941@awork2.anarazel.de
2016-03-21 12:22:54 +01:00
..
access Merge wal_level "archive" and "hot_standby" into new name "replica" 2016-03-18 23:56:03 +01:00
bootstrap Update copyright for 2016 2016-01-02 13:33:40 -05:00
catalog Merge wal_level "archive" and "hot_standby" into new name "replica" 2016-03-18 23:56:03 +01:00
commands Add simple VACUUM progress reporting. 2016-03-15 13:32:56 -04:00
common Add missing include for self-containment 2016-03-14 19:56:33 -04:00
datatype Be more careful about out-of-range dates and timestamps. 2016-03-16 19:09:28 -04:00
executor Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
foreign Directly modify foreign tables. 2016-03-18 13:55:52 -04:00
lib Add two HyperLogLog functions 2016-01-19 17:40:15 -03:00
libpq Introduce WaitEventSet API. 2016-03-21 12:22:54 +01:00
mb Update copyright for 2016 2016-01-02 13:33:40 -05:00
nodes Directly modify foreign tables. 2016-03-18 13:55:52 -04:00
optimizer Directly modify foreign tables. 2016-03-18 13:55:52 -04:00
parser Introduce parse_ident() 2016-03-18 18:16:14 +03:00
port Call xlc __isync() after, not before, associated compare-and-swap. 2016-02-19 22:47:50 -05:00
portability Update copyright for 2016 2016-01-02 13:33:40 -05:00
postmaster Allow the WAL writer to flush WAL at a reduced rate. 2016-02-16 00:56:34 +01:00
regex Suppress compiler warnings about useless comparison of unsigned to zero. 2016-02-15 17:12:16 -05:00
replication logical decoding: Fix handling of large old tuples with replica identity full. 2016-03-05 18:02:20 -08:00
rewrite Update copyright for 2016 2016-01-02 13:33:40 -05:00
snowball Update copyright for 2016 2016-01-02 13:33:40 -05:00
storage Introduce WaitEventSet API. 2016-03-21 12:22:54 +01:00
tcop Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
tsearch Improve support of Hunspell 2016-03-17 17:23:38 +03:00
utils Introduce parse_ident() 2016-03-18 18:16:14 +03:00
.gitignore Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
c.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
fmgr.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
funcapi.h Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
getaddrinfo.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
getopt_long.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
Makefile Install lwlocknames.h even in vpath builds. 2015-09-11 16:45:41 -04:00
miscadmin.h Add idle_in_transaction_session_timeout. 2016-03-16 11:30:45 -04:00
pg_config.h.in Introduce WaitEventSet API. 2016-03-21 12:22:54 +01:00
pg_config.h.win32 Cope if platform declares mbstowcs_l(), but not locale_t, in <xlocale.h>. 2016-03-15 13:19:57 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Change the way that LWLocks for extensions are allocated. 2016-02-04 16:43:04 -05:00
pg_getopt.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
pg_trace.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
pgstat.h Add simple VACUUM progress reporting. 2016-03-15 13:32:56 -04:00
pgtar.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
pgtime.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
port.h Add new system view, pg_config 2016-02-17 09:12:06 -08:00
postgres.h Widen query numbers-of-tuples-processed counters to uint64. 2016-03-12 16:05:29 -05:00
postgres_ext.h pgindent run for 9.4 2014-05-06 12:12:18 -04:00
postgres_fe.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
rusagestub.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
windowapi.h Update copyright for 2016 2016-01-02 13:33:40 -05:00