pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Cc: Petr Jelinek <petr@2ndquadrant.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: John Gorman <johngorman2@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: PATCH: two slab-like memory allocators
Date: Mon, 27 Feb 2017 22:57:24 -0500
Message-ID: <1240.1488254244@sss.pgh.pa.us> (raw)
In-Reply-To: <20170228034232.4h7ouyhxq4lbbao2@alap3.anarazel.de>
References: <b3b2245c-b37a-e1e5-ebc4-857c914bc747@2ndquadrant.com>
	<20170224221038.43xf2cyonczzr6hb@alap3.anarazel.de>
	<20170227111732.vrx5v72ighehwpkf@alap3.anarazel.de>
	<20170227120200.5jc3ubg5jrqaznd7@alap3.anarazel.de>
	<26061.1488209545@sss.pgh.pa.us>
	<20170227155532.o7casczq5parlmz4@alap3.anarazel.de>
	<20170227164828.akgzeg6ggl2v4x7s@alap3.anarazel.de>
	<12622.1488216468@sss.pgh.pa.us>
	<20170227174201.yrofai7neyp6shb2@alap3.anarazel.de>
	<c7c1bb85-d1d0-05a5-4d4c-3047d6f053e7@2ndquadrant.com>
	<20170228034232.4h7ouyhxq4lbbao2@alap3.anarazel.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Andres Freund <andres@anarazel.de> writes:
> Independently of this, we really should redefine StandardChunkHeader to
> be only the MemoryContext.  There's no need to have size/requested_size
> part of StandardChunkHeader, given there's
> MemoryContextMethods->get_chunk_space().

Yeah, perhaps.  The trick would be to get things laid out so that the 
MemoryContext pointer is always immediately adjacent to the chunk data
(no padding between).

One could imagine redefining aset.c's chunk header along the lines of

typedef struct AllocSetChunkHeader
{
    Size        size;             /* size of data space allocated in chunk */
#ifdef MEMORY_CONTEXT_CHECKING
    Size        requested_size;   /* original request size */
#if 32-bit-but-maxalign-is-8
    Size        padding;          /* needed to avoid padding below */
#endif
#endif
    MemoryContext context;        /* owning context */
    /* there must not be any padding to reach a MAXALIGN boundary here! */
} AllocSetChunkHeader;

where we'd possibly need some help from configure to implement that inner
#if condition, but it seems doable enough.

If the slab allocator would be happier with just a MemoryContext pointer
as chunk header, I think we should push in this direction rather than
invent some short-term hack.

			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



view thread (97+ messages)  latest in thread

Message-ID: <1240.1488254244@sss.pgh.pa.us>
Permalink:  ../1240.1488254244@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1240.1488254244@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, andres@anarazel.de, tomas.vondra@2ndquadrant.com, petr.jelinek@2ndquadrant.com, petr@2ndquadrant.com, robertmhaas@gmail.com, johngorman2@gmail.com
  Subject: Re: PATCH: two slab-like memory allocators
  In-Reply-To: <1240.1488254244@sss.pgh.pa.us>

* 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