pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Checkpoint sorting and balancing.
5+ messages / 3 participants
[nested] [flat]

* pgsql: Checkpoint sorting and balancing.
@ 2016-03-11 01:29  Andres Freund <andres@anarazel.de>
  0 siblings, 2 replies; 5+ messages in thread

From: Andres Freund @ 2016-03-11 01:29 UTC (permalink / raw)
  To: pgsql-committers

Checkpoint sorting and balancing.

Up to now checkpoints were written in the order they're in the
BufferDescriptors. That's nearly random in a lot of cases, which
performs badly on rotating media, but even on SSDs it causes slowdowns.

To avoid that, sort checkpoints before writing them out. We currently
sort by tablespace, relfilenode, fork and block number.

One of the major reasons that previously wasn't done, was fear of
imbalance between tablespaces. To address that balance writes between
tablespaces.

The other prime concern was that the relatively large allocation to sort
the buffers in might fail, preventing checkpoints from happening. Thus
pre-allocate the required memory in shared memory, at server startup.

This particularly makes it more efficient to have checkpoint flushing
enabled, because that'll often result in a lot of writes that can be
coalesced into one flush.

Discussion: alpine.DEB.2.10.1506011320000.28433@sto
Author: Fabien Coelho and Andres Freund

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/9cd00c457e6a1ebb984167ac556a9961812a683c

Modified Files
--------------
src/backend/storage/buffer/README     |   5 -
src/backend/storage/buffer/buf_init.c |  22 ++-
src/backend/storage/buffer/bufmgr.c   | 274 +++++++++++++++++++++++++++++-----
src/include/storage/buf_internals.h   |  18 +++
src/tools/pgindent/typedefs.list      |   2 +
5 files changed, 277 insertions(+), 44 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Checkpoint sorting and balancing.
@ 2016-03-11 01:47  Peter Eisentraut <peter_e@gmx.net>
  parent: Andres Freund <andres@anarazel.de>
  1 sibling, 1 reply; 5+ messages in thread

From: Peter Eisentraut @ 2016-03-11 01:47 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; pgsql-committers

On 3/10/16 8:29 PM, Andres Freund wrote:
> Checkpoint sorting and balancing.

This patch appears to have introduced a change that makes the build
with dtrace fail:

In file included from ../../../../src/include/pg_trace.h:15:0,
                 from bufmgr.c:42:
bufmgr.c: In function 'BufferSync':
bufmgr.c:1939:59: error: 'num_to_write' undeclared (first use in this function)
  TRACE_POSTGRESQL_BUFFER_SYNC_DONE(NBuffers, num_written, num_to_write);
                                                           ^
../../../../src/include/utils/probes.h:93:83: note: in definition of macro 'TRACE_POSTGRESQL_BUFFER_SYNC_DONE'
  __dtrace_probe$postgresql$buffer__sync__done$v1$696e74$696e74$696e74(arg0, arg1, arg2); \
                                                                                   ^~~~
bufmgr.c:1939:59: note: each undeclared identifier is reported only once for each function it appears in
  TRACE_POSTGRESQL_BUFFER_SYNC_DONE(NBuffers, num_written, num_to_write);
                                                           ^
../../../../src/include/utils/probes.h:93:83: note: in definition of macro 'TRACE_POSTGRESQL_BUFFER_SYNC_DONE'
  __dtrace_probe$postgresql$buffer__sync__done$v1$696e74$696e74$696e74(arg0, arg1, arg2); \
                                                                                   ^~~~



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Checkpoint sorting and balancing.
@ 2016-03-11 01:52  Andres Freund <andres@anarazel.de>
  parent: Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 5+ messages in thread

From: Andres Freund @ 2016-03-11 01:52 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-committers

On 2016-03-10 20:47:10 -0500, Peter Eisentraut wrote:
> On 3/10/16 8:29 PM, Andres Freund wrote:
> > Checkpoint sorting and balancing.
>
> This patch appears to have introduced a change that makes the build
> with dtrace fail:
>
> In file included from ../../../../src/include/pg_trace.h:15:0,
>                  from bufmgr.c:42:
> bufmgr.c: In function 'BufferSync':
> bufmgr.c:1939:59: error: 'num_to_write' undeclared (first use in this function)
>   TRACE_POSTGRESQL_BUFFER_SYNC_DONE(NBuffers, num_written, num_to_write);
>                                                            ^
> ../../../../src/include/utils/probes.h:93:83: note: in definition of macro 'TRACE_POSTGRESQL_BUFFER_SYNC_DONE'
>   __dtrace_probe$postgresql$buffer__sync__done$v1$696e74$696e74$696e74(arg0, arg1, arg2); \
>                                                                                    ^~~~
> bufmgr.c:1939:59: note: each undeclared identifier is reported only once for each function it appears in
>   TRACE_POSTGRESQL_BUFFER_SYNC_DONE(NBuffers, num_written, num_to_write);
>                                                            ^
> ../../../../src/include/utils/probes.h:93:83: note: in definition of macro 'TRACE_POSTGRESQL_BUFFER_SYNC_DONE'
>   __dtrace_probe$postgresql$buffer__sync__done$v1$696e74$696e74$696e74(arg0, arg1, arg2); \
>                                                                                    ^~~~

Hrmpf.  I tried to fix the issue; could you quickly verify?

These probes are a bit annoying; and I seriously doubt anybody actually
uses them. But obviously we should keep them working as long as we have
them.

Thanks!

Andres


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Checkpoint sorting and balancing.
@ 2016-03-11 02:36  Peter Eisentraut <peter_e@gmx.net>
  parent: Andres Freund <andres@anarazel.de>
  0 siblings, 0 replies; 5+ messages in thread

From: Peter Eisentraut @ 2016-03-11 02:36 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-committers

On 3/10/16 8:52 PM, Andres Freund wrote:
> Hrmpf.  I tried to fix the issue; could you quickly verify?

looks good



-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Checkpoint sorting and balancing.
@ 2016-03-11 03:46  Michael Paquier <michael.paquier@gmail.com>
  parent: Andres Freund <andres@anarazel.de>
  1 sibling, 0 replies; 5+ messages in thread

From: Michael Paquier @ 2016-03-11 03:46 UTC (permalink / raw)
  To: Andres Freund <andres@anarazel.de>; +Cc: pgsql-committers

On Fri, Mar 11, 2016 at 2:29 AM, Andres Freund <andres@anarazel.de> wrote:
> Checkpoint sorting and balancing.

+1.
-- 
Michael


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2016-03-11 03:46 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-11 01:29 pgsql: Checkpoint sorting and balancing. Andres Freund <andres@anarazel.de>
2016-03-11 01:47 ` Peter Eisentraut <peter_e@gmx.net>
2016-03-11 01:52   ` Andres Freund <andres@anarazel.de>
2016-03-11 02:36     ` Peter Eisentraut <peter_e@gmx.net>
2016-03-11 03:46 ` Michael Paquier <michael.paquier@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox