On Sat, Aug 6, 2022 at 10:53 AM Andrey Borodin <x4...@yandex-team.ru> wrote: > > Hi Bharath, > > thank you for the suggestion. > > > On 5 Aug 2022, at 16:02, Bharath Rupireddy > > <bharath.rupireddyforpostg...@gmail.com> wrote: > > > > On Thu, Aug 4, 2022 at 9:48 PM Andrey Borodin <x4...@yandex-team.ru> wrote: > >> > >>> On 18 Jul 2022, at 22:55, Robert Haas <robertmh...@gmail.com> wrote: > >>> > >>> On Thu, Jun 23, 2022 at 5:49 AM Jakub Wartak <jakub.war...@tomtom.com> > >>> wrote: > > > > I have a fundamental question on the overall idea - How beneficial it > > will be if the process that's reading the current WAL page only does > > (at least attempts) the prefetching of future WAL pages? Won't the > > benefit be higher if "some" other background process does prefetching? > > IMO prefetching from other thread would have negative effect. > fadvise() call is non-blocking, startup process won't do IO. It just informs > kernel to schedule asynchronous page read. > On the other hand synchronization with other process might cost more than > fadvise().
Hm, POSIX_FADV_WILLNEED flag makes fadvise() non-blocking. > Anyway cost of calling fadise() once per 16 page reads is neglectable. Agree. Why can't we just prefetch the entire WAL file once whenever it is opened for the first time? Does the OS have any limitations on max size to prefetch at once? It may sound aggressive, but it avoids fadvise() system calls, this will be especially useful if there are many WAL files to recover (crash, PITR or standby recovery), eventually we would want the total WAL file to be prefetched. If prefetching the entire WAL file is okay, we could further do this: 1) prefetch in XLogFileOpen() and all of segment_open callbacks, 2) release in XLogFileClose (it's being dong right now) and all of segment_close callbacks - do this perhaps optionally. Also, can't we use an existing function FilePrefetch()? That way, there is no need for a new wait event type. Thoughts? -- Bharath Rupireddy RDS Open Source Databases: https://aws.amazon.com/rds/postgresql/