pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Invent a memory context reset/delete callback mechanism.
7+ messages / 4 participants
[nested] [flat]

* pgsql: Invent a memory context reset/delete callback mechanism.
@ 2015-02-27 22:17 Tom Lane <tgl@sss.pgh.pa.us>
  2015-02-27 23:44 ` Re: pgsql: Invent a memory context reset/delete callback mechanism. Simon Riggs <simon@2ndQuadrant.com>
  2015-02-28 01:26 ` Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism. Jeff Davis <pgsql@j-davis.com>
  0 siblings, 2 replies; 7+ messages in thread

From: Tom Lane @ 2015-02-27 22:17 UTC (permalink / raw)
  To: pgsql-committers

Invent a memory context reset/delete callback mechanism.

This allows cleanup actions to be registered to be called just before a
particular memory context's contents are flushed (either by deletion or
MemoryContextReset).  The patch in itself has no use-cases for this, but
several likely reasons for wanting this exist.

In passing, per discussion, rearrange some boolean fields in struct
MemoryContextData so as to avoid wasted padding space.  For safety,
this requires making allowInCritSection's existence unconditional;
but I think that's a better approach than what was there anyway.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f65e8270587f3e9b8224e20f7d020ed1f816dfe1

Modified Files
--------------
src/backend/utils/mmgr/mcxt.c |   71 ++++++++++++++++++++++++++++++++++++-----
src/include/nodes/memnodes.h  |   24 +++++++++++---
src/include/utils/memutils.h  |    2 ++
3 files changed, 85 insertions(+), 12 deletions(-)


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


^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Invent a memory context reset/delete callback mechanism.
  2015-02-27 22:17 pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-02-27 23:44 ` Simon Riggs <simon@2ndQuadrant.com>
  2015-02-28 01:34   ` Re: pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 7+ messages in thread

From: Simon Riggs @ 2015-02-27 23:44 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers

On 27 February 2015 at 22:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Invent a memory context reset/delete callback mechanism.
>
> This allows cleanup actions to be registered to be called just before a
> particular memory context's contents are flushed (either by deletion or
> MemoryContextReset).  The patch in itself has no use-cases for this, but
> several likely reasons for wanting this exist.
>
> In passing, per discussion, rearrange some boolean fields in struct
> MemoryContextData so as to avoid wasted padding space.  For safety,
> this requires making allowInCritSection's existence unconditional;
> but I think that's a better approach than what was there anyway.

Please can you document this in src/backend/utils/mmgr/README or other place?

-- 
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, RemoteDBA, Training & Services


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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Invent a memory context reset/delete callback mechanism.
  2015-02-27 22:17 pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
  2015-02-27 23:44 ` Re: pgsql: Invent a memory context reset/delete callback mechanism. Simon Riggs <simon@2ndQuadrant.com>
@ 2015-02-28 01:34   ` Tom Lane <tgl@sss.pgh.pa.us>
  2015-03-01 16:27     ` Re: pgsql: Invent a memory context reset/delete callback mechanism. Simon Riggs <simon@2ndQuadrant.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2015-02-28 01:34 UTC (permalink / raw)
  To: Simon Riggs <simon@2ndQuadrant.com>; +Cc: pgsql-committers

Simon Riggs <simon@2ndQuadrant.com> writes:
> On 27 February 2015 at 22:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Invent a memory context reset/delete callback mechanism.

> Please can you document this in src/backend/utils/mmgr/README or other place?

Is anybody still reading that?  OK, done.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: pgsql: Invent a memory context reset/delete callback mechanism.
  2015-02-27 22:17 pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
  2015-02-27 23:44 ` Re: pgsql: Invent a memory context reset/delete callback mechanism. Simon Riggs <simon@2ndQuadrant.com>
  2015-02-28 01:34   ` Re: pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-03-01 16:27     ` Simon Riggs <simon@2ndQuadrant.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Simon Riggs @ 2015-03-01 16:27 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers

On 28 February 2015 at 01:34, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Simon Riggs <simon@2ndQuadrant.com> writes:
>> On 27 February 2015 at 22:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> Invent a memory context reset/delete callback mechanism.
>
>> Please can you document this in src/backend/utils/mmgr/README or other place?
>
> Is anybody still reading that?  OK, done.

There was a recent question about memory management, so people do ask
and that's still where we send 'em.

Thanks.

-- 
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, RemoteDBA, Training & Services


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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism.
  2015-02-27 22:17 pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-02-28 01:26 ` Jeff Davis <pgsql@j-davis.com>
  2015-02-28 01:42   ` Re: Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 7+ messages in thread

From: Jeff Davis @ 2015-02-28 01:26 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers; pgsql-hackers@postgresql.org; Andres Freund <andres@anarazel.de>; Tomas Vondra <tomas.vondra@2ndquadrant.com>

On Fri, 2015-02-27 at 22:17 +0000, Tom Lane wrote:
> In passing, per discussion, rearrange some boolean fields in struct
> MemoryContextData so as to avoid wasted padding space.  For safety,
> this requires making allowInCritSection's existence unconditional;
> but I think that's a better approach than what was there anyway.

I notice that this uses the bytes in MemoryContextData that I was hoping
to use for the memory accounting patch (for memory-bounded HashAgg).

Leaving no space for even a 32-bit value (without AllocSetContext
growing beyond the magical 192-byte number Andres mentioned) removes
most of the options for memory accounting. The only things I can think
of are:

  1. Move a few less-frequently-accessed fields out to an auxiliary
structure (Tomas proposed something similar); or
  2. Walk the memory contexts, but use some kind of
estimation/extrapolation so that it doesn't need to be done for every
input tuple of HashAgg.

Thoughts?

Regards,
	Jeff Davis





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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism.
  2015-02-27 22:17 pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
  2015-02-28 01:26 ` Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism. Jeff Davis <pgsql@j-davis.com>
@ 2015-02-28 01:42   ` Tom Lane <tgl@sss.pgh.pa.us>
  2015-02-28 02:16     ` Re: Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism. Stephen Frost <sfrost@snowman.net>
  0 siblings, 1 reply; 7+ messages in thread

From: Tom Lane @ 2015-02-28 01:42 UTC (permalink / raw)
  To: Jeff Davis <pgsql@j-davis.com>; +Cc: pgsql-hackers@postgresql.org; Andres Freund <andres@anarazel.de>; Tomas Vondra <tomas.vondra@2ndquadrant.com>

Jeff Davis <pgsql@j-davis.com> writes:
> On Fri, 2015-02-27 at 22:17 +0000, Tom Lane wrote:
>> In passing, per discussion, rearrange some boolean fields in struct
>> MemoryContextData so as to avoid wasted padding space.  For safety,
>> this requires making allowInCritSection's existence unconditional;
>> but I think that's a better approach than what was there anyway.

> I notice that this uses the bytes in MemoryContextData that I was hoping
> to use for the memory accounting patch (for memory-bounded HashAgg).

Meh.  I thought Andres' complaint about that was unfounded anyway ;-).
But I don't really see why a memory accounting patch should be expected to
have zero footprint.

			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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism.
  2015-02-27 22:17 pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
  2015-02-28 01:26 ` Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism. Jeff Davis <pgsql@j-davis.com>
  2015-02-28 01:42   ` Re: Re: [COMMITTERS] pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-02-28 02:16     ` Stephen Frost <sfrost@snowman.net>
  0 siblings, 0 replies; 7+ messages in thread

From: Stephen Frost @ 2015-02-28 02:16 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Jeff Davis <pgsql@j-davis.com>; pgsql-hackers@postgresql.org; Andres Freund <andres@anarazel.de>; Tomas Vondra <tomas.vondra@2ndquadrant.com>

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Jeff Davis <pgsql@j-davis.com> writes:
> > On Fri, 2015-02-27 at 22:17 +0000, Tom Lane wrote:
> >> In passing, per discussion, rearrange some boolean fields in struct
> >> MemoryContextData so as to avoid wasted padding space.  For safety,
> >> this requires making allowInCritSection's existence unconditional;
> >> but I think that's a better approach than what was there anyway.
> 
> > I notice that this uses the bytes in MemoryContextData that I was hoping
> > to use for the memory accounting patch (for memory-bounded HashAgg).
> 
> Meh.  I thought Andres' complaint about that was unfounded anyway ;-).
> But I don't really see why a memory accounting patch should be expected to
> have zero footprint.

For my 2c, I agree that it's a bit ugly to waste space due to padding,
but I'm all about improving the memory accounting and would feel that's
well worth having a slightly larger MemoryContextData.

In other words, I agree with Tom that it doesn't need to have a zero
footprint, but disagree about wasting space due to padding. :D

	Thanks!

		Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2015-03-01 16:27 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-02-27 22:17 pgsql: Invent a memory context reset/delete callback mechanism. Tom Lane <tgl@sss.pgh.pa.us>
2015-02-27 23:44 ` Simon Riggs <simon@2ndQuadrant.com>
2015-02-28 01:34   ` Tom Lane <tgl@sss.pgh.pa.us>
2015-03-01 16:27     ` Simon Riggs <simon@2ndQuadrant.com>
2015-02-28 01:26 ` Jeff Davis <pgsql@j-davis.com>
2015-02-28 01:42   ` Tom Lane <tgl@sss.pgh.pa.us>
2015-02-28 02:16     ` Stephen Frost <sfrost@snowman.net>

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