Re: increase size of pg_commit_ts buffers

From: Noah Misch <noah(at)leadboat(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: increase size of pg_commit_ts buffers
Date: 2021-02-15 10:40:04
Message-ID: 20210215104004.GA437900@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 15, 2021 at 07:07:44PM -0300, Alvaro Herrera wrote:
> I wrote this patch last year in response to a customer issue and I
> thought I had submitted it here, but evidently I didn't. So here it is.
>
> The short story is: in commit 5364b357fb11 we increased the size of
> pg_commit (née pg_clog) but we didn't increase the size of pg_commit_ts
> to match. When commit_ts is in use, this can lead to significant buffer
> thrashing and thus poor performance.
>
> Since commit_ts entries are larger than pg_commit, my proposed patch uses
> twice as many buffers.

This is a step in the right direction. With commit_ts entries being forty
times as large as pg_xact, it's not self-evident that just twice as many
buffers is appropriate. Did you try other numbers? I'm fine with proceeding
even if not, but the comment should then admit that the new number was a guess
that solved problems for one site.

> --- a/src/backend/access/transam/commit_ts.c
> +++ b/src/backend/access/transam/commit_ts.c
> @@ -530,7 +530,7 @@ pg_xact_commit_timestamp_origin(PG_FUNCTION_ARGS)

The comment right above here is outdated.

> Size
> CommitTsShmemBuffers(void)
> {
> - return Min(16, Max(4, NBuffers / 1024));
> + return Min(256, Max(4, NBuffers / 512));
> }
>
> /*

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-02-15 10:45:21 Re: ERROR: invalid spinlock number: 0
Previous Message Thomas Munro 2021-02-15 09:47:05 Re: ERROR: invalid spinlock number: 0