Only clear latch self-pipe/event if there is a pending notification.
authorAndres Freund <andres@anarazel.de>
Fri, 18 Mar 2016 18:43:59 +0000 (11:43 -0700)
committerAndres Freund <andres@anarazel.de>
Fri, 18 Mar 2016 18:47:05 +0000 (11:47 -0700)
commitc4901a1e03a7730e4471fd1143f1caf79695493d
tree179283f34e306ff45e71a7aa98ad9b06f7c4f864
parentc17966201c7de2a4c437bed6d83c6a7f2e7108f4
Only clear latch self-pipe/event if there is a pending notification.

This avoids a good number of, individually quite fast, system calls in
scenarios with many quick queries. Besides the aesthetic benefit of
seing fewer superflous system calls with strace, it also improves
performance by ~2% measured by pgbench -M prepared -c 96 -j 8 -S (scale
100).

Without having benchmarked it, this patch also adjust the windows code,
as that makes it easier to unify the unix/windows codepaths in a later
patch. There's little reason to diverge in behaviour between the
platforms.

Discussion: CA+TgmoYc1Zm+Szoc_Qbzi92z2c1vRHZmjhfPn5uC=w8bXv6Avg@mail.gmail.com
Reviewed-By: Robert Haas
src/backend/port/unix_latch.c
src/backend/port/win32_latch.c