Re: initdb and fsync
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Andres Freund <andres@2ndquadrant.com>, pgsql-hackers@postgresql.org, Peter Eisentraut <peter_e@gmx.net>
Date: 2012-07-13T22:11:37Z
Lists: pgsql-hackers
Jeff Davis <pgsql@j-davis.com> writes: > For the case of initdb, the data needing to be fsync'd is effectively > constant, and it's a lot of small files. If the requests don't make it > to the io scheduler queue before fsync, the kernel doesn't have an > opportunity to schedule them properly. > But for larger amounts of data copying (like ALTER DATABASE SET > TABLESPACE), it seemed like there was more risk that sync_file_range > would starve out other processes by continuously filling up the io > scheduler queue (I'm not sure if there are protections against that or > not). Also, if the files are larger, a single fsync represents more > data, and the kernel may be able to schedule it well enough anyway. > I'm not an authority in this area though, so if you are comfortable > extending sync_file_range to copydir() as well, that's fine with me. It could use some performance testing, which I don't have the time for (or proper equipment). Anyone? Also, I note that copy_file is set up so that it does sync_file_range or fadvise for each 64K chunk of data, which seems mighty small. I wonder if it'd be better to take that out of the loop and do one whole-file advise at the end of the copy loop. Or at least use some larger granularity for those calls. regards, tom lane