Re: slow dropping of tables, DropRelFileNodeBuffers, tas - Mailing list pgsql-hackers

From Simon Riggs
Subject Re: slow dropping of tables, DropRelFileNodeBuffers, tas
Date
Msg-id CA+U5nMJOQRKpxd_qi1vE75B7Oe7wr4nRJRaMj2XejxR54MpXDA@mail.gmail.com
Whole thread Raw
In response to Re: slow dropping of tables, DropRelFileNodeBuffers, tas  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Responses Re: slow dropping of tables, DropRelFileNodeBuffers, tas
Re: slow dropping of tables, DropRelFileNodeBuffers, tas
List pgsql-hackers
On 30 May 2012 12:10, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

> Hmm, we do this in smgrDoPendingDeletes:
>
> for (i = 0; i <= MAX_FORKNUM; i++)
> {
>        smgrdounlink(srel, i, false);
> }
>
> So we drop the buffers for each relation fork separately, which means that
> we scan the buffer pool four times. Relation forks in 8.4 introduced that
> issue, and 9.1 made it worse by adding another fork for unlogged tables.
> With some refactoring, we could scan the buffer pool just once. That would
> help a lot.

That struck me as a safe and easy optimisation. This was a problem I'd
been trying to optimise for 9.2, so I've written a patch that appears
simple and clean enough to be applied directly.

> Also, I wonder if DropRelFileNodeBuffers() could scan the pool without
> grabbing the spinlocks on every buffer? It could do an unlocked test first,
> and only grab the spinlock on buffers that need to be dropped.

Sounds less good and we'd need reasonable proof it actually did
anything useful without being dangerous.

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-hackers by date:

Previous
From: "Erik Rijkers"
Date:
Subject: Re: FailedAssertion("!(PrivateRefCount[i] == 0)", File: "bufmgr.c", Line: 1741
Next
From: Robert Haas
Date:
Subject: Re: FailedAssertion("!(PrivateRefCount[i] == 0)", File: "bufmgr.c", Line: 1741