Re: WIP: WAL prefetch (another approach)

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: WAL prefetch (another approach)
Date: 2020-03-02 05:43:23
Message-ID: CA+hUKG+5-C+EEaFFEYqqDrHjesdkX537H2_j9qL1i8Dq7yjoSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 12, 2020 at 7:52 PM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> 1. It now uses effective_io_concurrency to control how many
> concurrent prefetches to allow. It's possible that we should have a
> different GUC to control "maintenance" users of concurrency I/O as
> discussed elsewhere[1], but I'm staying out of that for now; if we
> agree to do that for VACUUM etc, we can change it easily here. Note
> that the value is percolated through the ComputeIoConcurrency()
> function which I think we should discuss, but again that's off topic,
> I just want to use the standard infrastructure here.

I started a separate thread[1] to discuss that GUC, because it's
basically an independent question. Meanwhile, here's a new version of
the WAL prefetch patch, with the following changes:

1. A monitoring view:

postgres=# select * from pg_stat_wal_prefetcher ;
prefetch | skip_hit | skip_new | skip_fpw | skip_seq | distance | queue_depth
----------+----------+----------+----------+----------+----------+-------------
95854 | 291458 | 435 | 0 | 26245 | 261800 | 10
(1 row)

That shows a bunch of counters for blocks prefetched and skipped for
various reasons. It also shows the current read-ahead distance (in
bytes of WAL) and queue depth (an approximation of how many I/Os might
be in flight, used for rate limiting; I'm struggling to come up with a
better short name for this). This can be used to see the effects of
experiments with different settings, eg:

alter system set effective_io_concurrency = 20;
alter system set wal_prefetch_distance = '256kB';
select pg_reload_conf();

2. A log message when WAL prefetching begins and ends, so you can see
what it did during crash recovery:

LOG: WAL prefetch finished at 0/C5E98758; prefetch = 1112628,
skip_hit = 3607540,
skip_new = 45592, skip_fpw = 0, skip_seq = 177049, avg_distance =
247907.942532,
avg_queue_depth = 22.261352

3. A bit of general user documentation.

[1] https://www.postgresql.org/message-id/flat/CA%2BhUKGJUw08dPs_3EUcdO6M90GnjofPYrWp4YSLaBkgYwS-AqA%40mail.gmail.com

Attachment Content-Type Size
0001-Allow-PrefetchBuffer-to-be-called-with-a-SMgrRelatio.patch text/x-patch 4.9 KB
0002-Rename-GetWalRcvWriteRecPtr-to-GetWalRcvFlushRecPtr.patch text/x-patch 4.4 KB
0003-Add-WalRcvGetWriteRecPtr-new-definition.patch text/x-patch 3.5 KB
0004-Allow-PrefetchBuffer-to-report-the-outcome.patch text/x-patch 6.8 KB
0005-Prefetch-referenced-blocks-during-recovery.patch text/x-patch 45.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-03-02 06:26:33 Re: ERROR: subtransaction logged without previous top-level txn record
Previous Message Surafel Temesgen 2020-03-02 05:39:00 Re: [PATCH v1] Allow COPY "text" to output a header and add header matching mode to COPY FROM