Re: Patch: Optimize memory allocation in function 'bringetbitmap'

From: "Jinyu Zhang" <beijing_pg(at)163(dot)com>
To: "Alvaro Herrera" <alvherre(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch: Optimize memory allocation in function 'bringetbitmap'
Date: 2015-10-16 18:00:13
Message-ID: 2ea866d6.5fd.15071cf2a8e.Coremail.beijing_pg@163.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Update the patch_brin_optimze_mem according to your comment.

At 2015-10-16 10:13:35, "Alvaro Herrera" <alvherre(at)2ndquadrant(dot)com> wrote:
>zhangjinyu wrote:
>
>> >>>>However I wonder if it would be simpler to have the dtup structure have
>> >>>>the pointers, so that you can pass it as NULL in the first call and then
>> >>>>followup calls reuse the one allocated in the first call.
>> Jinyu: the memory is allocated from perRangeCxt and perRangeCxt will be
>> reset in loop,
>> so this way don't work.
>
>You're right. I think we can do better: have brin_deform_tuple accept
>another argument of type BrinMemTuple *, which can be NULL. If NULL,
>the function calls brin_new_memtuple to allocate a new one (just like
>current code); if not NULL, that one is used. Have brin_new_memtuple
>also allocate the values/allnulls/hasnulls arrays, which are now part of
>the BrinMemTuple struct. Then, bringetbitmap calls brin_new_memtuple
>once before changing to perRangeCxt, then reuse the returned inside the
>loop (we probably need brin_memtuple_initialize to clear out the struct
>at the end of each loop iteration). Other callers of brin_deform_tuple
>just pass NULL to get the current behavior.
>
>--
>Álvaro Herrera http://www.2ndQuadrant.com/
>PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
>
>--
>Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
>To make changes to your subscription:
>http://www.postgresql.org/mailpref/pgsql-hackers

Attachment Content-Type Size
patch_brin_optimize_mem application/octet-stream 6.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-10-16 18:03:57 Re: Getting sorted data from foreign server
Previous Message Andres Freund 2015-10-16 17:51:44 Re: Proposal: SET ROLE hook