Re: Why is pq_begintypsend so slow?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jack Christensen <jack(at)jncsoftware(dot)com>, David Fetter <david(at)fetter(dot)org>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Why is pq_begintypsend so slow?
Date: 2020-07-31 17:35:43
Message-ID: CA+Tgmoa0NkJhTpo8k--joaT=L1kVovK5YozzRjf9eEJdnu5etA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 31, 2020 at 1:00 PM Andres Freund <andres(at)anarazel(dot)de> wrote:
> > Perhaps we could add a comment about this, e.g.
> > Marking these pointers with pg_restrict tells the compiler that str
> > and str->data can't overlap, which may allow the compiler to optimize
> > better when this code is inlined. For example, it may be possible to
> > keep str->data in a register across consecutive appendStringInfoString
> > operations.
> >
> > Since pg_restrict is not widely used, I think it's worth adding this
> > kind of annotation, lest other hackers get confused. I'm probably not
> > the only one who isn't on top of this.
>
> Would it make more sense to have a bit of an explanation at
> pg_restrict's definition, instead of having it at (eventually) multiple
> places?

I think, at least for the first few, it might be better to have a more
specific explanation at the point of use, as it may be easier to
understand in specific cases than in general. I imagine this only
really makes sense for places that are pretty hot.

> Ah, I misunderstood. Yea, there's no reason not to do that.

OK, then I vote for that version, as I think it looks nicer.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2020-07-31 17:39:37 Re: [Patch] Optimize dropping of relation buffers using dlist
Previous Message Andres Freund 2020-07-31 17:00:08 Re: Why is pq_begintypsend so slow?