| From: | Xuneng Zhou <xunengzhou(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | remove unused shared WAL flush request |
| Date: | 2026-11-25 04:22:29 |
| Message-ID: | CABPTF7Xz_9EX8K4wDEucopSM93jWVJ7U+R_+gtqAZmUs_Csa4w@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
It seems that XLogCtl->LogwrtRqst.Flush has long been unused; can we reduce
the shared request to a single write position?
Backends publish a shared write target so the WAL writer can know WAL to
write. For flushing, a backend calling XlogFlush() already knows the LSN it
needs made durable by checking shared flush progress and it performas the
flush itself if necessary. The WAL writer selects its work using the shared
write request and asyncXactLSN, then choose the flush target based on its
flush policy.
The shared Flush field doesn't participate in those decisions. Startup
initializes it, and XLogWrite() advances it to match finished flush
progress. XLogBackgroundFlush() copies it but overwrites the local value
before using it.
XLogFlush() stopped publishing its target there in 4d14fe0048c, and ad4295728e0
removed the remaining path that passed the shared flush value to
XLogWrite(). Since then, the field has still been updated but no longer
affects what gets flushed.
--- Effect on struct layout.
Removing it affects the struct layout of XLogCtlData. Now every field after
the request is shifted 8 bytes earlier. logInsertResult ends up on a
different cache line.
- With 64-byte lines, it moves from the line holding logWriteResult and
logFlushResult to the line holiding RedoRecPtr and asyncXactLSN
- With 128-byte lines, it joins the line that holds Insert.RedoRectPtr and
fullPageWrites.
I could not measure a difference on an 8-core x86-64 Linux machine or an
Apple ARM machine (128-byte lines). Bigger machines haven't been tested
yet. The workload is meant to call test XLogWrite() as often as possible
with fsync=off:
SELECT count(pg_logical_emit_message(false, 'b', 'xxxxxxxxxxxxxxxx', true))
FROM generate_series(1, 1000);
--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.
| Attachment | Content-Type | Size |
|---|---|---|
| flush-bench.sh | text/x-sh | 790 bytes |
| v1-0001-Remove-the-unused-shared-WAL-flush-request.patch | application/octet-stream | 5.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andreas Karlsson | 2026-11-25 04:23:06 | Re: Small cleanup of leftover pre-1.1.0 OpenSSL code |
| Previous Message | Ayush Tiwari | 2026-11-25 03:49:15 | Re: Small cleanup of leftover pre-1.1.0 OpenSSL code |