A sniffer for the buffer - Mailing list pgsql-hackers

From Jonas J
Subject A sniffer for the buffer
Date
Msg-id 68962a630912060754n3812dce2sa7e5a0296da66322@mail.gmail.com
Whole thread Raw
Responses Re: A sniffer for the buffer  (Greg Smith <greg@2ndquadrant.com>)
List pgsql-hackers
Hi,<br /><br />I'm a Computer Science student and I'm currently studying databases buffer managers.  I want to do some
experimentsand see how the pages access works in PostgreSQL. (and I also will do some I/O experiments)<br /><br />So, I
wantto do a "sniffer" on the Storage Layer of Postgresql. It should work telling me the page that PGSQL is reading or
writing.So when I make some operation on PGSQL, the pages that were requested (to read or write) by PGSQL for the
buffer,are stored in a separated file. And after that i can build some graphs, conclusions, etc...<br /><br />So, I
madesuch a code to do that, but i'm not quite sure if I'm doing the right thing. Can someone of you give me a opinion
??<br/><br />Many Thanks in advance,<br />Jonas Jeske<br /><br />The modified code is in bufmgr.c of PostgreSQL source
code.<br/><br />Buffer<br />ReadBuffer(Relation reln, BlockNumber blockNum)<br />{<br />    volatile BufferDesc
*bufHdr;<br/>    Block        bufBlock;<br />    bool        found;<br />    bool        isExtend;<br />    bool       
isLocalBuf;<br/><br />    /*jjeske starts here */<br />    FILE *fp;<br />    fp =
fopen("/home/jjeske/tpccuva/pgsql/saida.txt","a");   <br />    fprintf(fp,"Read Block n: %d\n",(int) blockNum);<br
/>   fclose(fp);<br /><br />....<br /><br />static void<br />write_buffer(Buffer buffer, bool unpin)<br />{<br />   
volatileBufferDesc *bufHdr;<br /><br />    /*jjeske starts here */<br />    FILE *fp;<br />    fp =
fopen("/home/jjeske/tpccuva/pgsql/saida.txt","a");   <br />     fprintf(fp,"Write Block n: %d\n",(int) buffer);<br
/>   fclose(fp);<br />....<br /><br /> 

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: operator exclusion constraints
Next
From: Simon Riggs
Date:
Subject: Re: Summary and Plan for Hot Standby