From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Jinyu Zhang <beijing_pg@163.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: Patch: Optimize memory allocation in function 'bringetbitmap'
Date: Sun, 27 Sep 2015 14:56:08 -0300
Message-ID: <20150927175608.GM295765@alvherre.pgsql> (raw)
In-Reply-To: <495deb78.4186.1500dacaa63.Coremail.beijing_pg@163.com>
References: <495deb78.4186.1500dacaa63.Coremail.beijing_pg@163.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Jinyu Zhang wrote:
>
> BRIN Scan: Optimize memory allocation in function 'bringetbitmap'.
> We can allocate memory for some pointer before do long loop instead of allocating
> memory in long loop.
>
> Before optimizing code (warm run)
> postgres=# select count(*) from lineitem where l_orderkey=1;
> Time: 456.219 ms
>
> After optimizing code (warm run)
> postgres=# select count(*) from lineitem where l_orderkey=1;
> Time: 349.219 ms
Hmm, did you measure this in a c-assert-enabled build? Those are slower
in allocation because of the memory-clobber thingy; without that, the
allocations would be a lot faster, so perhaps the gains are not so
interesting. Still, it's a lot of palloc/pfree calls that do not happen
with your patch, so perhaps it's still worthwhile, but please do measure
it.
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. That makes
the callers a bit less ugly, I think.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, beijing_pg@163.com
Subject: Re: Patch: Optimize memory allocation in function 'bringetbitmap'
In-Reply-To: <20150927175608.GM295765@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox