Way to check whether a particular block is on the shared_buffer? - Mailing list pgsql-hackers

From Kouhei Kaigai
Subject Way to check whether a particular block is on the shared_buffer?
Date
Msg-id 9A28C8860F777E439AA12E8AEA7694F8011A45F5@BPXM15GP.gisp.nec.co.jp
Whole thread Raw
Responses Re: Way to check whether a particular block is on the shared_buffer?
Re: Way to check whether a particular block is on the shared_buffer?
List pgsql-hackers
Hello,

Do we have a reliable way to check whether a particular heap block
is already on the shared buffer, but not modify?

Right now, ReadBuffer and ReadBufferExtended are entrypoint of the
buffer manager for extensions. However, it tries to acquire an
available buffer pool instead of the victim buffer, regardless of
the ReadBufferMode.

It is different from what I want to do:1. Check whether the supplied BlockNum is already loaded on the   shared
buffer.2.If yes, the caller gets buffer descriptor as usual ReadBuffer.3. If not, the caller gets InvalidBuffer without
modificationof   the shared buffer, also no victim buffer pool. 

It allows extensions (likely a custom scan provider) to take
different strategies for large table's scan, according to the
latest status of individual blocks.
If we don't have these interface, it seems to me an enhancement
of the ReadBuffer_common and (Local)BufferAlloc is the only way
to implement the feature.

Of course, we need careful investigation definition of the 'valid'
buffer pool. How about a buffer pool with BM_IO_IN_PROGRESS?
How about a buffer pool that needs storage extend (thus, no relevant
physical storage does not exists yet)? ... and so on.


As an aside, background of my motivation is the slide below:
http://www.slideshare.net/kaigai/sqlgpussd-english
(LT slides in JPUG conference last Dec)

I'm under investigation of SSD-to-GPU direct feature on top of
the custom-scan interface. It intends to load a bunch of data
blocks on NVMe-SSD to GPU RAM using P2P DMA, prior to the data
loading onto CPU/RAM, to preprocess the data to be filtered out.
It only makes sense if the target blocks are not loaded to the
CPU/RAM yet, because SSD device is essentially slower than RAM.
So, I like to have a reliable way to check the latest status of
the shared buffer, to kwon whether a particular block is already
loaded or not.

Thanks,
--
NEC Business Creation Division / PG-Strom Project
KaiGai Kohei <kaigai@ak.jp.nec.com>





pgsql-hackers by date:

Previous
From: Amit Langote
Date:
Subject: Re: [PROPOSAL] VACUUM Progress Checker.
Next
From: Sachin Kotwal
Date:
Subject: Re: Template for commit messages