From cfc22e4a0cf8597ef13b82c6e177ce90a2444d78 Mon Sep 17 00:00:00 2001 From: Kyotaro Horiguchi Date: Tue, 25 Oct 2016 18:05:30 +0900 Subject: [PATCH 4/4] Apply unlikely to suggest synchronous route of ExecAppend. ExecAppend seems to get slowed down by penalty of misprediction of branches related to async-execution. Apply unlikey to them to prevent such penalty on exiting route. Asynchronous execution is already having a lot of additional code so this doesn't add siginificant degradation. --- src/backend/executor/nodeAppend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index 2c07095..43e777f 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -214,7 +214,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags) TupleTableSlot * ExecAppend(AppendState *node) { - if (node->as_nasyncplans > 0) + if (unlikely(node->as_nasyncplans > 0)) { EState *estate = node->ps.state; int i; @@ -255,7 +255,7 @@ ExecAppend(AppendState *node) /* * if we have async requests outstanding, run the event loop */ - if (node->as_nasyncpending > 0) + if (unlikely(node->as_nasyncpending > 0)) { long timeout = node->as_syncdone ? -1 : 0; -- 2.9.2