[PATCH] Use MemoryContextAlloc() in the MemoryContextAllocZero() and MemoryContextAllocZeroAligned()

Started by Alexander Kuleshovabout 10 years ago3 messageshackers
Jump to latest
#1Alexander Kuleshov
kuleshovmail@gmail.com

Hello all,

Attached patch simplifies the MemoryContextAllocZero() and
MemoryContextAllocZeroAligned().
The MemoryContextAllocZero() and MemoryContextAllocZeroAligned()
functions does almost the
same that MemoryContextAlloc() does. Additionally these functions
fills allocated memory context
with zeros via MemSetAligned() and MemSetLoop(). Let's call
MemoryContextAlloc() in these functions
instead of setting isReset to false, call alloc() callback of the
context and etc., to prevent code duplication.

Attachments:

mm-context-simplify-alloc.patchtext/x-patch; charset=US-ASCII; name=mm-context-simplify-alloc.patchDownload+2-40
#2Michael Paquier
michael@paquier.xyz
In reply to: Alexander Kuleshov (#1)
Re: [PATCH] Use MemoryContextAlloc() in the MemoryContextAllocZero() and MemoryContextAllocZeroAligned()

On Sat, Mar 12, 2016 at 8:09 AM, Alexander Kuleshov
<kuleshovmail@gmail.com> wrote:

Hello all,

Attached patch simplifies the MemoryContextAllocZero() and
MemoryContextAllocZeroAligned().
The MemoryContextAllocZero() and MemoryContextAllocZeroAligned()
functions does almost the
same that MemoryContextAlloc() does. Additionally these functions
fills allocated memory context
with zeros via MemSetAligned() and MemSetLoop(). Let's call
MemoryContextAlloc() in these functions
instead of setting isReset to false, call alloc() callback of the
context and etc., to prevent code duplication.

This code duplication is on purpose. This is a very hot code path and
we want to avoid the overhead of an extra function call.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alexander Kuleshov (#1)
Re: [PATCH] Use MemoryContextAlloc() in the MemoryContextAllocZero() and MemoryContextAllocZeroAligned()

Alexander Kuleshov <kuleshovmail@gmail.com> writes:

Attached patch simplifies the MemoryContextAllocZero() and
MemoryContextAllocZeroAligned().

What this does is to de-inline those functions, resulting in an
extra level of function call per allocation. We had intentionally
inlined them on performance grounds: those things are hot spots in
most workloads. Do you have any evidence demonstrating that this
doesn't cause a performance hit?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers