Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 87bff68

Browse files
committed
pgbench: When using pipelining only do PQconsumeInput() when necessary.
Up to now we did a PQconsumeInput() for each pipelined query, asking the OS for more input - which it often won't have, as all results might already have been sent. That turns out to have a noticeable performance impact. Alvaro Herrera reviewed the idea to add the PQisBusy() check, but not this concrete patch. Author: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/20210720180039.23rivhdft3l4mayn@alap3.anarazel.de Backpatch: 14, where libpq/pgbench pipelining was introduced.
1 parent 1bc8e7b commit 87bff68

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/pgbench/pgbench.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -3461,7 +3461,14 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
34613461
*/
34623462
case CSTATE_WAIT_RESULT:
34633463
pg_log_debug("client %d receiving", st->id);
3464-
if (!PQconsumeInput(st->con))
3464+
3465+
/*
3466+
* Only check for new network data if we processed all data
3467+
* fetched prior. Otherwise we end up doing a syscall for each
3468+
* individual pipelined query, which has a measurable
3469+
* performance impact.
3470+
*/
3471+
if (PQisBusy(st->con) && !PQconsumeInput(st->con))
34653472
{
34663473
/* there's something wrong */
34673474
commandFailed(st, "SQL", "perhaps the backend died while processing");

0 commit comments

Comments
 (0)