On Mon, Nov 23, 2026 at 1:20 PM Markos Fountoulakis <[email protected]> wrote: > > [..v06112026..] > > Hi Jakub, > > I reviewed the patch-set a bit, my biggest issue is with the use of > fallocate(): > - In general fallocate() has proven to be a bit problematic depending on the > filesystem implementation of it (e.g. [1]), i.e. performance may regress on a > network filesystem or a CoW one. > - Moreover, erroring out with FATAL for ENOSPC seems problematic to me: > - I think it is simpler in general to let the write() fail with ENOSPC > (instead of fallocate()), which also should fail at a later time which may be > desirable > - which is especially true in the case of overextending DIO_PREALLOC_CHUNK > and potentially failing with ENOSPC when less real space is required >
Hi Markos, Thank You for reviewing and sorry for late response! Yes, that's a valid problem and I admit I've completley forgot about those woes with XFS [it was kernel bug], but more importantly on btrfs disarming output compression, so yes it's good finding. As You mention, it also struck me now e.g. on older NFS it could be even mean that glibc fallback could kick in for posix_fadvise() could start wriitng zeroes, so sounds we need a away to shut it down. On another hand the fallocate() however is required to get really good speeds on ext4/xfs which is way more comamnd and there are 3 places patchset uses it today: 1.It happened just that it was one of the first patches (v1/0007 see initial post and there it was just +7%) , but to me it looks like if I would just reverse the sequence between those two: v06112026-0008-pg_basebackup-preallocate-extracted-files-.patch v06112026-0009-libpq-pg_basebackup-add-PQgetCopyDataInter.patch (and would do 0009 first and only then 0008, then it would be even bigger hit). I remember it had to do something with number/frequency of fs extents allocated and probably just avoiding delayed allocation if memory serves me well (doing everything in one go, rather than on potentially per-write() writeback). 2.It was absolutley crucial on plain-output (-Fd) for AIO/DIO (v06112026-0010) from what I remember. 3.It is clearly how much effective it is - for the -Ft - with v06112026-0011 that not having it slows from 410MB/s -> 2.3GB/s, well AFAIR because every touch of metadata there is sync IO (and there's plenty of it there without batching preallocation in one big go at first), but patch is separate just because I had to measure/demonstrate the benefit of it alone here. > To conclude I am in favour of removing fallocate() altogether from this work, > otherwise at least remove all the ENOSPC checks and maybe let it fail at the > write() syscall stage instead. What if we would add an user to opt-out of it? So adding another PG_BASEBACKUP_NOFALLOCATE (as we have PG_BASEBACKUP_NODIO already) or just add pg_basebackup --no-fallocate? (There's --sync-method=syncfs tweak already there already). IMHO we cannot just fetch file_extend_method GUC as it affects server as the pg_basebackup could be running somewhere else and would output to different fstype/media. Some thoughts on this? -J.
