A sniffer for the buffer

From: Jonas J <autoramajj(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: A sniffer for the buffer
Date: 2009-12-06 15:54:59
Message-ID: 68962a630912060754n3812dce2sa7e5a0296da66322@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I'm a Computer Science student and I'm currently studying databases buffer
managers. I want to do some experiments and see how the pages access works
in PostgreSQL. (and I also will do some I/O experiments)

So, I want to 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...

So, I made such 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 ??

Many Thanks in advance,
Jonas Jeske

The modified code is in bufmgr.c of PostgreSQL source code.

Buffer
ReadBuffer(Relation reln, BlockNumber blockNum)
{
volatile BufferDesc *bufHdr;
Block bufBlock;
bool found;
bool isExtend;
bool isLocalBuf;

/*jjeske starts here */
FILE *fp;
fp = fopen("/home/jjeske/tpccuva/pgsql/saida.txt","a");
fprintf(fp,"Read Block n: %d\n",(int) blockNum);
fclose(fp);

....

static void
write_buffer(Buffer buffer, bool unpin)
{
volatile BufferDesc *bufHdr;

/*jjeske starts here */
FILE *fp;
fp = fopen("/home/jjeske/tpccuva/pgsql/saida.txt","a");
fprintf(fp,"Write Block n: %d\n",(int) buffer);
fclose(fp);
....

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2009-12-06 15:56:49 Re: Summary and Plan for Hot Standby
Previous Message Tom Lane 2009-12-06 15:46:48 Re: operator exclusion constraints