Skip site navigation (1) Skip section navigation (2)

Moving more work outside WALInsertLock

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Moving more work outside WALInsertLock
Date: 2011-12-15 13:51:33
Message-ID: 4EE9FB65.3040604@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-hackers
I've been looking at various ways to make WALInsertLock less of a 
bottleneck on multi-CPU servers. The key is going to be to separate the 
two things that are done while holding the WALInsertLock: a) allocating 
the required space in the WAL, and b) calculating the CRC of the record 
header and copying the data to the WAL page. a) needs to be serialized, 
but b) could be done in parallel.

I've been experimenting with different approaches to do that, but one 
thing is common among all of them: you need to know the total amount of 
WAL space needed for the record, including backup blocks, before you 
take the lock. So, here's a patch to move things around in XLogInsert() 
a bit, to accomplish that.

This patch doesn't seem to have any performance or scalability impact. I 
must admit I expected it to give a tiny gain in scalability by 
shortening the time WALInsertLock is held by a few instructions, but I 
can't measure any. But IMO it makes the code more readable, so this is 
worthwhile for that reason alone.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Attachment: xloginsert-bkp-refactor-1.patch
Description: text/x-diff (9.6 KB)

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2011-12-15 14:13:22
Subject: Re: Race condition in HEAD, possibly due to PGPROC splitup
Previous:From: Alvaro HerreraDate: 2011-12-15 13:37:59
Subject: Re: patch : Allow toast tables to be moved to a different tablespace

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group