Hi Hackers,

We host many PG instances on each of our machines, and we want to minimize
the calls to fsync within each instance, in order to minimize possible
impact on other instances. We found there is a fsync call when CLOG buffer
is written out in SlruPhysicalWritePage(). It is often called when a backend
needs to check transaction status with SimpleLruReadPage().


The code is as follows (in src/backend/access/transam/slru.c line 837 in PG
9.4):
/*
 * If not part of Flush, need to fsync now.  We assume this happens
 * infrequently enough that it's not a performance issue.
 */
if (!fdata)
{
if (ctl->do_fsync && pg_fsync(fd))
{
slru_errcause = SLRU_FSYNC_FAILED;
slru_errno = errno;
CloseTransientFile(fd);
return false;
}

if (CloseTransientFile(fd))
{
slru_errcause = SLRU_CLOSE_FAILED;
slru_errno = errno;
return false;
}

 ctl->do_fsync is true for CLOG.  Question is, could we just disable fsync
for CLOG buffer write out here? Is it safe to do so? I understand a
checkpoint will calls SimpleLruFlush to flush all CLOG buffer at once, and
the fsync call here (for buffer write out) is not necessary.

Thanks for your time!
Guangzhou


Reply via email to