pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: Stephen Frost <sfrost@snowman.net>
To: pgsql-hackers@postgresql.org
Subject: Re: pgsql: Use pre-fetching for ANALYZE
Date: Thu, 2 Jun 2022 19:30:16 -0700
Message-ID: <20220603023016.rlht3r7fmkksw5z7@alap3.anarazel.de> (raw)
In-Reply-To: <E1lMEjg-0006Mm-Na@gemulon.postgresql.org>
References: <E1lMEjg-0006Mm-Na@gemulon.postgresql.org>

Hi,

On 2021-03-16 18:48:08 +0000, Stephen Frost wrote:
> Use pre-fetching for ANALYZE
> 
> When we have posix_fadvise() available, we can improve the performance
> of an ANALYZE by quite a bit by using it to inform the kernel of the
> blocks that we're going to be asking for.  Similar to bitmap index
> scans, the number of buffers pre-fetched is based off of the
> maintenance_io_concurrency setting (for the particular tablespace or,
> if not set, globally, via get_tablespace_maintenance_io_concurrency()).

I just looked at this as part of debugging a crash / hang in the AIO patch.

The code does:

		block_accepted = table_scan_analyze_next_block(scan, targblock, vac_strategy);

#ifdef USE_PREFETCH

		/*
		 * When pre-fetching, after we get a block, tell the kernel about the
		 * next one we will want, if there's any left.
		 *
		 * We want to do this even if the table_scan_analyze_next_block() call
		 * above decides against analyzing the block it picked.
		 */
		if (prefetch_maximum && prefetch_targblock != InvalidBlockNumber)
			PrefetchBuffer(scan->rs_rd, MAIN_FORKNUM, prefetch_targblock);
#endif

I.e. we lock a buffer and *then* we prefetch another buffer. That seems like a
quite bad idea to me. Why are we doing IO while holding a content lock, if we
can avoid it?

Greetings,

Andres Freund





view thread (4+ messages)  latest in thread

Message-ID: <20220603023016.rlht3r7fmkksw5z7@alap3.anarazel.de>
Permalink:  ../20220603023016.rlht3r7fmkksw5z7@alap3.anarazel.de/
Also on:    postgresql.org/message-id/20220603023016.rlht3r7fmkksw5z7@alap3.anarazel.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, sfrost@snowman.net, pgsql-hackers@postgresql.org
  Subject: Re: pgsql: Use pre-fetching for ANALYZE
  In-Reply-To: <20220603023016.rlht3r7fmkksw5z7@alap3.anarazel.de>
  References: <E1lMEjg-0006Mm-Na@gemulon.postgresql.org> <20220603023016.rlht3r7fmkksw5z7@alap3.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox