Re: initdb and fsync

From: Andres Freund <andres(at)anarazel(dot)de>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: initdb and fsync
Date: 2012-03-14 09:26:17
Message-ID: 201203141026.17799.andres@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday, March 14, 2012 05:23:03 AM Jeff Davis wrote:
> On Tue, 2012-03-13 at 09:42 +0100, Andres Freund wrote:
> > for recursively everything in dir:
> > posix_fadvise(fd, POSIX_FADV_DONTNEED);
> >
> > for recursively everything in dir:
> > fsync(fd);
>
> Wow, that made a huge difference!
>
> no sync: ~ 1.0s
> sync: ~10.0s
> fadvise+sync: ~ 1.3s
>
> Patch attached.
>
> Now I feel much better about it. Most people will either have fadvise, a
> write cache (rightly or wrongly), or actually need the sync. Those that
> have none of those can use -N.
Well, while the positive effect of this are rather large it also has the bad
effect of pushing the whole new database out of the cache. Which is not so nice
if you want to run tests on it seconds later.
How are the results with sync_file_range(fd, 0, 0,
SYNC_FILE_RANGE_WRITE)?

Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vlad Arkhipov 2012-03-14 11:25:10 Weird behaviour
Previous Message Simon Riggs 2012-03-14 08:28:30 Re: Too many IO?