Re: using file cloning in create database / initdb

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: using file cloning in create database / initdb
Date: 2022-08-01 18:15:22
Message-ID: 20220801181522.GK15006@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Feb 12, 2022 at 07:37:30PM -0800, Andres Freund wrote:
> On 2022-02-12 20:17:46 -0600, Justin Pryzby wrote:
> > On Sat, Feb 12, 2022 at 06:00:44PM -0800, Andres Freund wrote:
> > > I bet using COW file copies would speed up our own regression tests noticeably
> > > - on slower systems we spend a fair bit of time and space creating template0
> > > and postgres, with the bulk of the data never changing.
> > >
> > > Template databases are also fairly commonly used by application developers to
> > > avoid the cost of rerunning all the setup DDL & initial data loading for
> > > different tests. Making that measurably cheaper would be a significant win.
> >
> > +1
> >
> > I ran into this last week and was still thinking about proposing it.
> >
> > Would this help CI
>
> It could theoretically help linux - but currently I think the filesystem for
> CI is ext4, which doesn't support FICLONE. I assume it'd help macos, but I
> don't know the performance characteristics of copyfile(). I don't think any of
> the other OSs have working reflink / file clone support.
>
> You could prototype it for CI on macos by using the "template initdb" patch
> and passing -c to cp.

Yes, copyfile() in CREATE DATABASE seems to help cirrus/darwin a bit.
https://cirrus-ci.com/task/5277139049119744

On xfs:
postgres=# CREATE DATABASE new3 TEMPLATE postgres STRATEGY FILE_COPY ;
2022-07-31 00:21:28.350 CDT [2347] LOG: checkpoint starting: immediate force wait flush-all
...
CREATE DATABASE
Time: 1296.243 ms (00:01.296)

postgres=# CREATE DATABASE new4 TEMPLATE postgres STRATEGY FILE_CLONE;
2022-07-31 00:21:38.697 CDT [2347] LOG: checkpoint starting: immediate force wait flush-all
...
CREATE DATABASE
Time: 167.152 ms

--
Justin

Attachment Content-Type Size
0001-WIP-support-file-cloning-in-CREATE-DATABASE.patch text/x-diff 11.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Naeem Akhter 2022-08-01 18:28:54 Re: Allow pageinspect's bt_page_stats function to return a set of rows instead of a single row
Previous Message Justin Pryzby 2022-08-01 18:11:36 Re: fix typos