Re: MemoryContext reset/delete callbacks

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: MemoryContext reset/delete callbacks
Date: 2015-02-27 00:57:17
Message-ID: 20150227005717.GC10102@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-02-27 01:54:27 +0100, Andres Freund wrote:
> On 2015-02-26 19:28:50 -0500, Tom Lane wrote:
> > /*
> > *************** typedef struct MemoryContextData
> > *** 59,72 ****
> > MemoryContext firstchild; /* head of linked list of children */
> > MemoryContext nextchild; /* next child of same parent */
> > char *name; /* context name (just for debugging) */
> > bool isReset; /* T = no space alloced since last reset */
> > #ifdef USE_ASSERT_CHECKING
> > ! bool allowInCritSection; /* allow palloc in critical section */
> > #endif
> > } MemoryContextData;
>
> It's a bit sad to push AllocSetContextData onto four cachelines from the
> current three... That stuff is hot. But I don't really see a way around
> it right now. And it seems like it'd give us more amunition to improve
> things than the small loss of speed it implies.

Actually:
struct MemoryContextData {
NodeTag type; /* 0 4 */

/* XXX 4 bytes hole, try to pack */

MemoryContextMethods * methods; /* 8 8 */
MemoryContext parent; /* 16 8 */
MemoryContext firstchild; /* 24 8 */
MemoryContext nextchild; /* 32 8 */
char * name; /* 40 8 */
bool isReset; /* 48 1 */
bool allowInCritSection; /* 49 1 */

/* size: 56, cachelines: 1, members: 8 */
/* sum members: 46, holes: 1, sum holes: 4 */
/* padding: 6 */
/* last cacheline: 56 bytes */
};

If we move isReset and allowInCritSection after type, we'd stay at the
same size...

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-02-27 00:57:35 Re: Partitioning WIP patch
Previous Message Andres Freund 2015-02-27 00:54:27 Re: MemoryContext reset/delete callbacks