diff options
| author | Simon Riggs | 2010-12-08 18:48:03 +0000 |
|---|---|---|
| committer | Simon Riggs | 2010-12-08 18:48:03 +0000 |
| commit | e620ee35b249b0af255ef788003d1c9edb815a35 (patch) | |
| tree | e8b04c9426be8a7abdb95c69b97b6b9f17513bf1 /src/backend/storage/ipc/procarray.c | |
| parent | 5a031a5556ff83b8a9646892715d7fef415b83c3 (diff) | |
Optimize commit_siblings in two ways to improve group commit.
First, avoid scanning the whole ProcArray once we know there
are at least commit_siblings active; second, skip the check
altogether if commit_siblings = 0.
Greg Smith
Diffstat (limited to 'src/backend/storage/ipc/procarray.c')
| -rw-r--r-- | src/backend/storage/ipc/procarray.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index ff08f869e2c..980996e5eb8 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -1886,20 +1886,25 @@ CancelVirtualTransaction(VirtualTransactionId vxid, ProcSignalReason sigmode) } /* - * CountActiveBackends --- count backends (other than myself) that are in - * active transactions. This is used as a heuristic to decide if + * MinimumActiveBackends --- count backends (other than myself) that are + * in active transactions. Return true if the count exceeds the + * minimum threshold passed. This is used as a heuristic to decide if * a pre-XLOG-flush delay is worthwhile during commit. * * Do not count backends that are blocked waiting for locks, since they are * not going to get to run until someone else commits. */ -int -CountActiveBackends(void) +bool +MinimumActiveBackends(int min) { ProcArrayStruct *arrayP = procArray; int count = 0; int index; + /* Quick short-circuit if no minimum is specified */ + if (min == 0) + return true; + /* * Note: for speed, we don't acquire ProcArrayLock. This is a little bit * bogus, but since we are only testing fields for zero or nonzero, it @@ -1932,9 +1937,11 @@ CountActiveBackends(void) if (proc->waitLock != NULL) continue; /* do not count if blocked on a lock */ count++; + if (count >= min) + break; } - return count; + return count >= min; } /* |
