Re: make BufferGetBlockNumber() a macro

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: make BufferGetBlockNumber() a macro
Date: 2002-04-01 22:59:06
Message-ID: 16578.1017701946@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> The attached patch re-implements BufferGetBlockNumber() as a macro,
> for performance reasons.

The trouble with this is that it forces storage/buf_internals.h to
become part of bufmgr.h, thereby completely destroying any information
hiding that we had from the division of the two headers --- any client
of bufmgr.h might now access bufmgr internal stuff without noticing
that it was doing wrong.

I am not convinced that BufferGetBlockNumber is a bottleneck anyway;
at least not if you don't have Assert checking enabled.

There are a few places that do things like
ItemPointerSet(&(tuple->t_self), BufferGetBlockNumber(buffer), offnum);
which I believe results in two calls to BufferGetBlockNumber because of
the way BlockIdSet is coded. This would be good to clean up, but it's
BlockIdSet's problem not BufferGetBlockNumber's.

> It also adds an assertion that should probably
> be present.

FWIW, BufferIsPinned also checks BufferIsValid; you do not need both.

regards, tom lane

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2002-04-02 00:49:05 Re: make BufferGetBlockNumber() a macro
Previous Message Neil Conway 2002-04-01 21:13:53 make BufferGetBlockNumber() a macro