| From: | Gustavo William <gustavowilliam0805(at)gmail(dot)com> |
|---|---|
| To: | Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: enhancing pg_basebackup speeds up to ~23Gbps (small fixes + io_uring/Direct I/O) |
| Date: | 2026-09-22 19:39:58 |
| Message-ID: | CANdV9nUtaeNwf8CiPfHP8gDxgnZFp+W9Mxco68N4=GJ9Pt_UAQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Jakub,
Thanks for reviewing it. I'm resending the chain of patches here, with 0005
already merged + your suggestions applied.
Here is a summary of what I've fixed:
> I've forgotten to support incremental mode (which means that I ended up
issuing posix_fadvise SEQUENTIAL even in incremental mode
1. Fixed. Only issue posix_fadvise SEQUENTIAL for full backups and only
issue posix_fadvise WILLNEED for incremental backups.
> there's bug that when m_io_c = 0 you still issue posix_fadvise()s from
2nd callsite (no way to turn it off) and also with e.g. m_io_c = 1 we seem
to issue an additional one.
2. Fixed this by only calling prefetch_next_incremental_run when m_io_c >
1. Also moved the call to happen after read_file_data_into_buffer instead
of before. Both changes together make the prefetching logic a little more
honest regarding I/O queue depth, i.e:
- When m_io_c = 0 or m_io_c = 1: no prefetching at all, queue depth is
constantly1 (the synchronous block read).
- When m_io_c > 1 (e.g. 2): prefetch 2 initially > read 1 + prefetch 1 >
read 1 + prefetch 1... on average, there will always be 2 I/O
simultaneously (assuming fadvise calls are honored).
> I'm not sure f that merging of adjacent blocks shouldn't be also capped
up a io_combine_limit GUC
3. Agree that capping is good there. Though I think
maintenance_io_concurrency can be reused for this purpose instead? I think
a new GUC for this might be too specific. I currently have it implemented
using m_io_c. Let me know your thoughts on this if you think otherwise.
> I would rename pf_index to just prefetch_idx, so it would easier to read.
4. Agreed. Fixed.
Thanks,
Gustavo Oliveira
| Attachment | Content-Type | Size |
|---|---|---|
| v22092026-0001-pg_basebackup-rename-the-blackhole-backup-.patch | application/octet-stream | 5.1 KB |
| v22092026-0002-pg_basebackup-add-new-client-blackhole-ben.patch | application/octet-stream | 16.5 KB |
| v22092026-0003-pg_basebackup-report-average-data-transfer.patch | application/octet-stream | 3.0 KB |
| v22092026-0004-basebackup-bump-SINK_BUFFER_LENGTH-to-256k.patch | application/octet-stream | 1.3 KB |
| v22092026-0005-basebackup-issue-posix_fadvise-for-more-ef.patch | application/octet-stream | 6.8 KB |
| v22092026-0006-pg_basebackup-elimiate-usage-of-libc-to-co.patch | application/octet-stream | 6.6 KB |
| v22092026-0007-pg_basebackup-preallocate-extracted-files-.patch | application/octet-stream | 2.8 KB |
| v22092026-0008-libpq-pg_basebackup-add-PQgetCopyDataInter.patch | application/octet-stream | 7.2 KB |
| v22092026-0009-pg_basebackup-add-support-for-Direct-I-O-a.patch | application/octet-stream | 22.6 KB |
| v22092026-0010-pg_basebackup-preallocate-DIO-writes-also-.patch | application/octet-stream | 6.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jim Jones | 2026-09-22 19:49:00 | Re: COMMENTS are not being copied in CREATE TABLE LIKE |
| Previous Message | Merlin Moncure | 2026-09-22 19:34:06 | Up to 50x degradation in dblink performance when receiving notice traffic 19 vs 18 |