Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C9926637ABA for ; Tue, 2 Feb 2010 14:49:28 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 59954-01-9 for ; Tue, 2 Feb 2010 18:49:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f218.google.com (mail-bw0-f218.google.com [209.85.218.218]) by mail.postgresql.org (Postfix) with ESMTP id 6F96865A1EC for ; Tue, 2 Feb 2010 14:06:28 -0400 (AST) Received: by bwz10 with SMTP id 10so352238bwz.35 for ; Tue, 02 Feb 2010 10:06:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=SvyTXALw+i9vILXn4yvxLN4rAUibKo1A4HeN0/d1yhY=; b=i4MMpBfdR0QOK/k9Ck72nMDaCb60KFYoVhGnz6DrnBiBr+Smr2T0aI700TuHnPCEcm tz6SJvdtVjiT2ijzAniswDoYNKvGljIrBefVpnxp4mS6bPe2R8evI8WATK8XCOsuziNh q2afqyNsaJNd1vTgcZK2p7iYRmv5OvfRhdiSo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=xi7+oAk4YWquDEgEmJ4luS/1tghTFI+Af4TBY14CQGuH8JZjUJkfAq/PSgHKtcTkOg 5/3qCGjvIqLjiOjdPOnY/FfpLV1vNinmxn/JxkCOjKH43G5cVaEwCCsviCl1H1ZNYw+d oW4OBWuKoysfHLj7VgLuj7oLFWhI1G4WXSIck= MIME-Version: 1.0 Received: by 10.239.189.137 with SMTP id t9mr338005hbh.176.1265132172464; Tue, 02 Feb 2010 09:36:12 -0800 (PST) In-Reply-To: <407d949e1001291056q22915b1cqbce5fbc918a15d69@mail.gmail.com> 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> <407d949e1001291056q22915b1cqbce5fbc918a15d69@mail.gmail.com> Date: Tue, 2 Feb 2010 12:36:12 -0500 Message-ID: <603c8f071002020936k5723e30kd4eac594092aba3b@mail.gmail.com> Subject: Re: [HACKERS] Re: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb) From: Robert Haas To: Greg Stark Cc: Tom Lane , Andres Freund , pgsql-hackers@postgresql.org, pgsql-performance@postgresql.org, Michael Clemmons , Hannu Krosing , Scott Marlowe Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.472 tagged_above=-10 required=5 tests=AWL=0.127, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/16 X-Sequence-Number: 37437 On Fri, Jan 29, 2010 at 1:56 PM, Greg Stark wrote: > On Tue, Jan 19, 2010 at 3:25 PM, Tom Lane wrote: >> That function *seriously* needs documentation, in particular the fact >> that it's a no-op on machines without the right kernel call. =A0The name >> you've chosen is very bad for those semantics. =A0I'd pick something >> else myself. =A0Maybe "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(). I took a look at this patch today and I agree with Tom that pg_fsync_start() is a very confusing name. I don't know what the right name is, but this doesn't fsync so I don't think it shuld have fsync in the name. Maybe something like pg_advise_abandon() or pg_abandon_cache(). The current name is really wishful thinking: you're hoping that it will make the kernel start the fsync, but it might not. I think pg_start_data_flush() is similarly optimistic. ...Robert