Re: Deferring some AtStart* allocations? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Deferring some AtStart* allocations?
Date
Msg-id 9226.1404090769@sss.pgh.pa.us
Whole thread Raw
In response to Re: Deferring some AtStart* allocations?  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Deferring some AtStart* allocations?  (Andres Freund <andres@2ndquadrant.com>)
Re: Deferring some AtStart* allocations?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Andres Freund <andres@2ndquadrant.com> writes:
> On 2014-06-29 19:52:23 -0400, Tom Lane wrote:
>> Andres Freund <andres@2ndquadrant.com> writes:
>>> Why aren't we delaying allocations in e.g. AtStart_Inval(),
>>> AfterTriggerBeginXact() to when the data structures are acutally used?
>> 
>> Aren't we?  Neither of those would be doing much work certainly.

> They are perhaps not doing much in absolute terms, but it's a fair share
> of the processing overhead for simple statements. AfterTriggerBeginXact()
> is called unconditionally from StartTransaction() and does three
> MemoryContextAlloc()s. AtStart_Inval() one.
> I think they should just be initialized whenever the memory is used?
> Doesn't look too complicated to me.

Meh.  Even "SELECT 1" is going to be doing *far* more pallocs than that to
get through raw parsing, parse analysis, planning, and execution startup.
If you can find a few hundred pallocs we can avoid in trivial queries,
it would get interesting; but I'll be astonished if saving 4 is measurable.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Deferring some AtStart* allocations?
Next
From: Andres Freund
Date:
Subject: Re: idle_in_transaction_timeout