diff options
| author | Robert Haas | 2011-11-14 15:04:55 +0000 |
|---|---|---|
| committer | Robert Haas | 2011-12-02 11:35:30 +0000 |
| commit | 0755cb5964c0b33d1894add7bb3a80dbc11a4fb6 (patch) | |
| tree | a75523a57795a38b9e7f93036ecb45af82977107 /src/backend/commands/analyze.c | |
| parent | f98db4f264ea655f713536db5eed89ebf9531191 (diff) | |
Reimplement ProcArrayLock as a new type of FlexLock.flexlock
By providing some custom handling for ProcArrayEndTransaction, we can
avoid the need for ending transactions to repeatedly acquire the
spinlock. The amount of work that needs to be done while holding the
lock is so small that we can do it while holding the spinlock, or
(when the lock is contended) make the last person to release the lock
do it on behalf of the ending backend. This greatly improves
performance for unlogged tables at high client counts; permanent
tables also benefit, but performance is still severely throttled by
WALInsertLock contention.
Diffstat (limited to 'src/backend/commands/analyze.c')
| -rw-r--r-- | src/backend/commands/analyze.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 314324618a..2e972ec280 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -40,6 +40,7 @@ #include "storage/lmgr.h" #include "storage/proc.h" #include "storage/procarray.h" +#include "storage/procarraylock.h" #include "utils/acl.h" #include "utils/attoptcache.h" #include "utils/datum.h" @@ -222,9 +223,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt, BufferAccessStrategy bstrategy) /* * OK, let's do it. First let other backends know I'm in ANALYZE. */ - LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); + ProcArrayLockAcquire(PAL_EXCLUSIVE); MyPgXact->vacuumFlags |= PROC_IN_ANALYZE; - LWLockRelease(ProcArrayLock); + ProcArrayLockRelease(); /* * Do the normal non-recursive ANALYZE. @@ -249,9 +250,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt, BufferAccessStrategy bstrategy) * Reset my PGPROC flag. Note: we need this here, and not in vacuum_rel, * because the vacuum flag is cleared by the end-of-xact code. */ - LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); + ProcArrayLockAcquire(PAL_EXCLUSIVE); MyPgXact->vacuumFlags &= ~PROC_IN_ANALYZE; - LWLockRelease(ProcArrayLock); + ProcArrayLockRelease(); } /* |
