public inbox for [email protected]  
help / color / mirror / Atom feed
From: Drouvot, Bertrand <[email protected]>
To: Matthias van de Meent <[email protected]>
To: Konstantin Knizhnik <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Speed-up shared buffers prewarming
Date: Thu, 16 Mar 2023 12:50:35 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAEze2WjJckQm0SfRuMXs8fMYtgpS++bkHEGkcmqNVgnrZte-5g@mail.gmail.com>
References: <[email protected]>
	<CAEze2WjJckQm0SfRuMXs8fMYtgpS++bkHEGkcmqNVgnrZte-5g@mail.gmail.com>

Hi,

On 3/15/23 10:40 PM, Matthias van de Meent wrote:
> On Wed, 15 Mar 2023 at 21:38, Konstantin Knizhnik <[email protected]> wrote:
>>
>> Hi hackers,
>>
>> It is well known fact that queries using sequential scan can not be used to prewarm cache, because them are using ring buffer
>> even if shared buffers are almost empty.
>> I have searched hackers archive but failed to find any discussion about it.
>> What are the drawbacks of using free buffers even with BAM_BULKREAD strategy?
>> I mean the following trivial patch:
>>
>> diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c
>> index 6be80476db..243335d0e4 100644
>> --- a/src/backend/storage/buffer/freelist.c
>> +++ b/src/backend/storage/buffer/freelist.c
>> @@ -208,8 +208,15 @@ StrategyGetBuffer(BufferAccessStrategy strategy, uint32 *buf_state)
>>          /*
>>           * If given a strategy object, see whether it can select a buffer. We
>>           * assume strategy objects don't need buffer_strategy_lock.
>>           */
>> -       if (strategy != NULL)
>> +       if (strategy != NULL && StrategyControl->firstFreeBuffer < 0)
>>          {
>>                  buf = GetBufferFromRing(strategy, buf_state);
>>                  if (buf != NULL)
>>
>> So if there are free buffers, then use normal buffer allocation instead of GetBufferFromRing.
> 
> Yes. As seen in [1], ring buffers aren't all that great in some cases,
> and I think this is one. Buffer allocation should always make use of
> the available resources, so that it doesn't take O(N/ring_size) scans
> on a table to fill the buffers if that seqscan is the only workload of
> the system.

Agree but then what do you think about also paying special attention to those buffers when eviction needs to be done?

Those buffers are "usually" needed briefly, so something like being able to distinguish them and be more aggressive regarding their eviction.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com






view thread (3+ messages)

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Speed-up shared buffers prewarming
  In-Reply-To: <[email protected]>

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

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