pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org, Michael Clemmons <glassresistor@gmail.com>
Cc: Hannu Krosing <hannu@2ndquadrant.com>
Cc: Scott Marlowe <scott.marlowe@gmail.com>
Subject: Re: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb)
Date: Fri, 29 Jan 2010 18:56:23 +0000
Message-ID: <407d949e1001291056q22915b1cqbce5fbc918a15d69@mail.gmail.com> (raw)
In-Reply-To: <9319.1263914746@sss.pgh.pa.us>
References: <4427a97a0912101235x3ade510blcc00d5ce9883c6b6@mail.gmail.com>
	<200912282354.51892.andres@anarazel.de>
	<200912282359.43979.andres@anarazel.de>
	<200912291930.50812.andres@anarazel.de>
	<407d949e1001180835m79ffe3e4w53e20ce2e1a58f2d@mail.gmail.com>
	<407d949e1001190652i43f4f276x6a485f375647219a@mail.gmail.com>
	<9319.1263914746@sss.pgh.pa.us>

On Tue, Jan 19, 2010 at 3:25 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> That function *seriously* needs documentation, in particular the fact
> that it's a no-op on machines without the right kernel call.  The name
> you've chosen is very bad for those semantics.  I'd pick something
> else myself.  Maybe "pg_start_data_flush" or something like that?
>

I would like to make one token argument in favour of the name I
picked. If it doesn't convince I'll change it since we can always
revisit the API down the road.

I envision having two function calls, pg_fsync_start() and
pg_fsync_finish(). The latter will wait until the data synced in the
first call is actually synced. The fall-back if there's no
implementation of this would be for fsync_start() to be a noop (or
something unreliable like posix_fadvise) and fsync_finish() to just be
a regular fsync.

I think we can accomplish this with sync_file_range() but I need to
read up on how it actually works a bit more. In this case it doesn't
make a difference since when we call fsync_finish() it's going to be
for the entire file and nothing else will have been writing to these
files. But for wal writing and checkpointing it might have very
different performance characteristics.

The big objection to this is that then we don't really have an api for
FADV_DONT_NEED which is more about cache policy than about syncing to
disk. So for example a sequential scan might want to indicate that it
isn't planning on reading the buffers it's churning through but
doesn't want to force them to be written sooner than otherwise and is
never going to call fsync_finish().



-- 
greg



view thread (70+ messages)  latest in thread

Message-ID: <407d949e1001291056q22915b1cqbce5fbc918a15d69@mail.gmail.com>
Permalink:  ../407d949e1001291056q22915b1cqbce5fbc918a15d69@mail.gmail.com/
Also on:    postgresql.org/message-id/407d949e1001291056q22915b1cqbce5fbc918a15d69@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: gsstark@mit.edu, tgl@sss.pgh.pa.us, andres@anarazel.de, glassresistor@gmail.com, hannu@2ndquadrant.com, scott.marlowe@gmail.com
  Subject: Re: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb)
  In-Reply-To: <407d949e1001291056q22915b1cqbce5fbc918a15d69@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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