Group Commit

Lists: pgsql-hackers
From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Group Commit
Date: 2011-11-14 10:08:01
Message-ID: CA+U5nM+yHxCmatc_M7bFHGe27GEgFkxmDdLX1s4mSuuCGdSwxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Enclosed patch implements Group Commit and also powersave mode for WALWriter.

XLogFlush() waits for WALWriter to run XLogBackgroundFlush(), which
flushes WAL and then wakes waiters. Uses same concepts and similar
code to sync rep.

Purpose is to provide consistent WAL writes, even when WALInsertLock
contended. Currently no "off" option, thinking is that the overhead of
doing this is relatively low and so it can be "always on" - exactly as
it is for sync rep.

WALWriter now has variable wakeups, so wal_writer_delay is removed.
Commit_delay and Commit_siblings are now superfluous and are also removed.

Works, but needs discussion in some areas, docs and possibly tuning
first, so this is more of a quicky than a slow, comfortable patch.

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

Attachment Content-Type Size
group_commit.v2.patch application/octet-stream 37.8 KB

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Group Commit
Date: 2011-11-14 20:43:19
Message-ID: 4EC17D67.8080901@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


> Purpose is to provide consistent WAL writes, even when WALInsertLock
> contended. Currently no "off" option, thinking is that the overhead of
> doing this is relatively low and so it can be "always on" - exactly as
> it is for sync rep.

Hmmm, have you had a chance to do any performance tests?

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


From: Greg Smith <greg(at)2ndQuadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Group Commit
Date: 2011-11-14 21:37:34
Message-ID: 4EC18A1E.8030909@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 11/14/2011 03:43 PM, Josh Berkus wrote:
>
>> Purpose is to provide consistent WAL writes, even when WALInsertLock
>> contended. Currently no "off" option, thinking is that the overhead of
>> doing this is relatively low and so it can be "always on" - exactly as
>> it is for sync rep.
>>
> Hmmm, have you had a chance to do any performance tests?
>

I was planning to run some later this week, but someone else is welcome
to take a shot at it. The inspiration for this change was the
performance scaling tests I did for sync rep last month. Don't recall
if I shared those with this list yet; I've attached the fun graph. Over
a slow international link with 100ms ping times, I was only getting the
expected 10 TPS doing sync rep with a single client. But as more
clients were added, so that a chunk of them were acknowledged in each
commit reply, the total throughput among all of them scaled near
linearly. With 300 clients, that managed to hit a crazy 2000 TPS.

The best scenario to show this patch working would be a laptop drive
spinning at a slow speed (5400 or 4200 RPM) so that individual local
commits are slow. That won't be 100ms slow, but close to 10ms is easy
to see. When adding clients to a system with a slow local commit, what
I've observed is that the scaling levels off between 750 and 1000 TPS,
no matter how many clients are involved. The hope is that this
alternate implementation will give the higher scaling in the face of
slow commits that is seen on sync rep.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us

Attachment Content-Type Size
image/png 4.4 KB

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Group Commit
Date: 2011-11-16 00:18:07
Message-ID: CAMkU=1w5pLv5=P_pNhP3CHD6AeSGQO+R_2Sekq6EeWDttAhP-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Nov 14, 2011 at 2:08 AM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
> Enclosed patch implements Group Commit and also powersave mode for WALWriter.
>
> XLogFlush() waits for WALWriter to run XLogBackgroundFlush(), which
> flushes WAL and then wakes waiters. Uses same concepts and similar
> code to sync rep.
>
> Purpose is to provide consistent WAL writes, even when WALInsertLock
> contended. Currently no "off" option, thinking is that the overhead of
> doing this is relatively low and so it can be "always on" - exactly as
> it is for sync rep.
>
> WALWriter now has variable wakeups, so wal_writer_delay is removed.
> Commit_delay and Commit_siblings are now superfluous and are also removed.
>
> Works, but needs discussion in some areas, docs and possibly tuning
> first, so this is more of a quicky than a slow, comfortable patch.

When I apply this to HEAD and run make check, it freezes at:
test tablespace ...

The wal writer process is running at 100% CPU. The only thing it is
doing that is visible though strace is checking that the postmaster is
alive.

I see the same behavior on two different Linux boxes, 32 bit and 64
bit. I've tried to do some debugging, but haven't made much head-way.
Does anyone else see this?

Cheers,

Jeff


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Group Commit
Date: 2011-11-16 01:17:43
Message-ID: CA+Tgmob24ek+L7YKQ351kRKq2=KTR7+KiQFb+N3ZVunyM2WtCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Nov 15, 2011 at 7:18 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> When I apply this to HEAD and run make check, it freezes at:
> test tablespace               ...
[...]
>  Does anyone else see this?

It hangs for me, too, just slightly later:

============== running regression test queries ==============
test tablespace ... ok
parallel group (18 tests): name txid oid float4 text int2 int4 int8
char varchar uuid float8 money boolean bit enum numeric

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Group Commit
Date: 2011-11-16 08:18:42
Message-ID: CA+U5nMJ0MC3aE-MvemJ4sy=6X3DT6D6JxNQqS--tjtexy6E3uw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Nov 16, 2011 at 1:17 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Tue, Nov 15, 2011 at 7:18 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
>> When I apply this to HEAD and run make check, it freezes at:
>> test tablespace               ...
> [...]
>>  Does anyone else see this?
>
> It hangs for me, too, just slightly later:

OK, thanks for checking. I'll investigate.

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