Re: [pgsql-patches] Ctid chain following enhancement

Lists: pgsql-patches
From: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
To: pgsql-patches(at)postgresql(dot)org
Subject: Ctid chain following enhancement
Date: 2007-01-27 05:50:17
Message-ID: 2e78013d0701262150i7e48018br27fbd3ce0309cf2e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Attached is a patch which should marginally improve the ctid chain followin
code path when current and the next tuple in the chain are in the same
block.

In the current code, we unconditionally drop pin of the current block
without
checking whether the next tuple is the same block or not. ISTM that this can
be improved.

The attached patch replaces the heap_fetch() with heap_release_fetch() in
EvalPlanQual() and thus releases the buffer iff the chain gets into a
different block.
Similarly, ReadBuffer() is replaced with ReleaseAndReadBuffer() in
heap_get_latest_tid() for the same reason. The buffer is set to
InvalidBuffer
to start with and is not released at the end of the loop.
heap_release_fetch()/
ReleaseAndReadBuffer() would release it if required.

Thanks,
Pavan

--

EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
cf-enhance-head.patch application/octet-stream 3.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Ctid chain following enhancement
Date: 2007-01-27 16:16:01
Message-ID: 6212.1169914561@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

"Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com> writes:
> Attached is a patch which should marginally improve the ctid chain followin
> code path when current and the next tuple in the chain are in the same
> block.

It looks to me that you have introduced a buffer leak into
heap_get_latest_tid ... which is quite unlikely to be worth optimizing
anyway. EvalPlanQual is not exactly a performance-critical path either,
and given how hard that code is to understand at all, complicating it
for marginal performance gains seems dubious.

regards, tom lane


From: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Ctid chain following enhancement
Date: 2007-01-27 20:21:04
Message-ID: 2e78013d0701271221v723bee48h2a7d8ebe3a002987@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On 1/27/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>
> It looks to me that you have introduced a buffer leak into
> heap_get_latest_tid ...

I can't spot that. A previously pinned buffer is released at the start
of the loop if we are moving to a different block. Otherwise, the buffer
is released at all places where the for(;;) loop is terminated by a "break".
Am I missing something ?

Thanks,
Pavan

--

EnterpriseDB http://www.enterprisedb.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Ctid chain following enhancement
Date: 2007-01-27 21:17:11
Message-ID: 23118.1169932631@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

"Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com> writes:
> On 1/27/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> It looks to me that you have introduced a buffer leak into
>> heap_get_latest_tid ...

> I can't spot that.

No, you're right, my apologies. I was thinking that the patch ought to
introduce an UnlockReleaseBuffer after the loop, but that's not
necessary given the calls before all the breaks. (OTOH it might be
cleaner to refactor things that way, if we were going to apply this.
I still don't think heap_get_latest_tid is worth any optimization
effort, though.)

regards, tom lane


From: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Ctid chain following enhancement
Date: 2007-01-29 07:19:33
Message-ID: 2e78013d0701282319g595c3cb7x44289ac1264103@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On 1/28/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> OTOH it might be
> cleaner to refactor things that way, if we were going to apply this.
>
>
Here is a revised patch which includes refactoring of
heap_get_latest_tid(), as per Tom's suggestion.

Thanks,
Pavan

--

EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
cf-enhance-head-v2.patch application/octet-stream 4.8 KB

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-02-20 20:57:10
Message-ID: 200702202057.l1KKvAd26331@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

It will be applied as soon as one of the PostgreSQL committers reviews
and approves it.

---------------------------------------------------------------------------

Pavan Deolasee wrote:
> On 1/28/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > OTOH it might be
> > cleaner to refactor things that way, if we were going to apply this.
> >
> >
> Here is a revised patch which includes refactoring of
> heap_get_latest_tid(), as per Tom's suggestion.
>
> Thanks,
> Pavan
>
> --
>
> EnterpriseDB http://www.enterprisedb.com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
To: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-05-29 13:55:27
Message-ID: 465C30CF.5080105@sun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Pavan Deolasee wrote:
>
> On 1/28/07, *Tom Lane* <tgl(at)sss(dot)pgh(dot)pa(dot)us <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>>
> wrote:
>
> OTOH it might be
> cleaner to refactor things that way, if we were going to apply this.
>
>
> Here is a revised patch which includes refactoring of
> heap_get_latest_tid(), as per Tom's suggestion.
>

I'm looking on your patch. I have one comment:

If you have old tid and new tid you can easy compare if new tid points
to different page? And if page is still same there is no reason to
Unlock it and lock again. I think add inner loop something like:

Readbufer
Lock
do{

...

} while(ctid.block_id == tid.block_id)
ReleaseAndUnlock

can save some extra locking/unlocking cycle. What do you think?

Zdenek


From: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
To: "Zdenek Kotala" <Zdenek(dot)Kotala(at)sun(dot)com>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-05-30 13:27:01
Message-ID: 2e78013d0705300627w32a7afedr28fd44a3159aaef4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On 5/29/07, Zdenek Kotala <Zdenek(dot)Kotala(at)sun(dot)com> wrote:
>
>
> I'm looking on your patch. I have one comment:
>
> If you have old tid and new tid you can easy compare if new tid points
> to different page? And if page is still same there is no reason to
> Unlock it and lock again. I think add inner loop something like:
>
>
Tom has already expressed his unwillingness to add complexity
without any proven benefits. Your suggestion though good would
make the code more unreadable without much benefit since the
function is not called very often.

Thanks,
Pavan

--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com


From: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
To: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-05-30 13:43:58
Message-ID: 465D7F9E.8040702@sun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Pavan Deolasee napsal(a):
>
> On 5/29/07, *Zdenek Kotala* <Zdenek(dot)Kotala(at)sun(dot)com
> <mailto:Zdenek(dot)Kotala(at)sun(dot)com>> wrote:
>
>
> I'm looking on your patch. I have one comment:
>
> If you have old tid and new tid you can easy compare if new tid points
> to different page? And if page is still same there is no reason to
> Unlock it and lock again. I think add inner loop something like:
>
>
> Tom has already expressed his unwillingness to add complexity
> without any proven benefits. Your suggestion though good would
> make the code more unreadable without much benefit since the
> function is not called very often.

OK. I think Bruce can remove your patch from pipeline?

Zdenek


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-06-01 19:04:10
Message-ID: 200706011904.l51J4AP06067@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


This has been saved for the 8.4 release:

http://momjian.postgresql.org/cgi-bin/pgpatches_hold

---------------------------------------------------------------------------

Pavan Deolasee wrote:
> On 1/28/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > OTOH it might be
> > cleaner to refactor things that way, if we were going to apply this.
> >
> >
> Here is a revised patch which includes refactoring of
> heap_get_latest_tid(), as per Tom's suggestion.
>
> Thanks,
> Pavan
>
> --
>
> EnterpriseDB http://www.enterprisedb.com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-06-01 19:52:20
Message-ID: 22518.1180727540@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> This has been saved for the 8.4 release:

I think it should be dropped entirely. The argument against was that
it complicated the code in a non-performance-critical path, and that
argument isn't going to be different next time.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-06-01 20:49:16
Message-ID: 200706012049.l51KnGN00943@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > This has been saved for the 8.4 release:
>
> I think it should be dropped entirely. The argument against was that
> it complicated the code in a non-performance-critical path, and that
> argument isn't going to be different next time.

I only kept it for 8.4 because I was worried it might be needed for HOT
performance. Are we sure that is not the case because that is why it
was originally proposed.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-06-01 20:58:12
Message-ID: 23449.1180731492@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Tom Lane wrote:
>> I think it should be dropped entirely. The argument against was that
>> it complicated the code in a non-performance-critical path, and that
>> argument isn't going to be different next time.

> I only kept it for 8.4 because I was worried it might be needed for HOT
> performance.

No such argument has been made in my hearing, and I can't imagine why
either of the functions touched by the patch would be more
performance-critical for HOT than they are today.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-06-01 21:10:04
Message-ID: 200706012110.l51LA4l04523@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Patch rejected, not held for 8.4, because it uglifies the code.

---------------------------------------------------------------------------

Pavan Deolasee wrote:
> On 1/28/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >
> > OTOH it might be
> > cleaner to refactor things that way, if we were going to apply this.
> >
> >
> Here is a revised patch which includes refactoring of
> heap_get_latest_tid(), as per Tom's suggestion.
>
> Thanks,
> Pavan
>
> --
>
> EnterpriseDB http://www.enterprisedb.com

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-06-01 21:11:36
Message-ID: 200706012111.l51LBac04678@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > Tom Lane wrote:
> >> I think it should be dropped entirely. The argument against was that
> >> it complicated the code in a non-performance-critical path, and that
> >> argument isn't going to be different next time.
>
> > I only kept it for 8.4 because I was worried it might be needed for HOT
> > performance.
>
> No such argument has been made in my hearing, and I can't imagine why
> either of the functions touched by the patch would be more
> performance-critical for HOT than they are today.

OK, removed from 8.4 queue.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: "Pavan Deolasee" <pavan(dot)deolasee(at)gmail(dot)com>
To: "Bruce Momjian" <bruce(at)momjian(dot)us>
Cc: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: [pgsql-patches] Ctid chain following enhancement
Date: 2007-06-02 02:38:27
Message-ID: 2e78013d0706011938m73fe6922q142d104d5bbbef25@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On 6/2/07, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>
>
>
> OK, removed from 8.4 queue.
>
>
>
I am OK with this, though I personally never felt that it complicated
the code :-)

Thanks,
Pavan

--
Pavan Deolasee
EnterpriseDB http://www.enterprisedb.com