where are the getting buf data from disk really done?

Started by sunpengalmost 16 years ago3 messagesgeneral
Jump to latest
#1sunpeng
bluevaley@gmail.com

I noticed at the function StartBufferIO() in bufmgr.c, there is no really
getting buffer data from disk, only set InProgressBuf = buf; and return
true;
i wondered where is the getting buf data from disk really done?
are there a background process to do this work? which function does this
work?
thanks!

peng

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: sunpeng (#1)
Re: where are the getting buf data from disk really done?

sunpeng <bluevaley@gmail.com> writes:

I noticed at the function StartBufferIO() in bufmgr.c, there is no really
getting buffer data from disk, only set InProgressBuf = buf; and return
true;
i wondered where is the getting buf data from disk really done?

The caller. StartBufferIO is only concerned with interlocking multiple
backends that might try to read (or write) the same buffer.

regards, tom lane

#3Greg Smith
gsmith@gregsmith.com
In reply to: sunpeng (#1)
Re: where are the getting buf data from disk really done?

sunpeng wrote:

I noticed at the function StartBufferIO() in bufmgr.c, there is no
really getting buffer data from disk, only set InProgressBuf = buf;
and return true;
i wondered where is the getting buf data from disk really done?
are there a background process to do this work? which function does
this work?

That's done by ReadBuffer_common in that same bit of source code. The
call to smgrread is the one that does the read from disk. StartBufferIO
is actually part of the buffer allocation code, used to lock things so
that only one backend tries to read in a buffer that more than one might
want. Some highlights of the main code path here:

ReadBuffer | ReadBufferExtended | ReadBufferWithoutRelcache
ReadBuffer_common
BufferAlloc
StrategyGetBuffer
StartBufferIO
smgrread

There is no background process involved at any point here. The only
background process related to the buffer cache in the current PostgreSQL
implementation alternates between writing out checkpoint data and
writing dirty buffers that haven't been used recently, in hopes of
speeding up the BufferAlloc section here. Everything else is done
directly by the client backends.

--
Greg Smith 2ndQuadrant US Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com www.2ndQuadrant.us