pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add transparent block-level memory accounting
Date: Tue, 01 Oct 2019 01:53:18 +0000
Message-ID: <E1iF7Lq-0008Sg-FC@gemulon.postgresql.org> (raw)

Add transparent block-level memory accounting

Adds accounting of memory allocated in a memory context. Compared to
various ad hoc solutions, the main advantage is that the accounting is
transparent and does not require direct control over allocations (this
matters for use cases where the allocations happen in user code, like
for example aggregate states allocated in a transition functions).

To reduce overhead, the accounting happens at the block level (not for
individual chunks) and only the context immediately owning the block is
updated. When inquiring about amount of memory allocated in a context,
we have to recursively walk all children contexts.

This "lazy" accounting works well for cases with relatively small number
of contexts in the relevant subtree and/or with infrequent inquiries.

Author: Jeff Davis
Reivewed-by: Tomas Vondra, Melanie Plageman, Soumyadeep Chakraborty
Discussion: https://www.postgresql.org/message-id/flat/027a129b8525601c6a680d27ce3a7172dab61aab.camel@j-davis.co...

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5dd7fc1519461548eebf26c33eac6878ea3e8788

Modified Files
--------------
src/backend/utils/mmgr/README       | 34 +++++++++++++++++++++++++++++++++
src/backend/utils/mmgr/aset.c       | 38 +++++++++++++++++++++++++++++++++++++
src/backend/utils/mmgr/generation.c | 12 ++++++++++++
src/backend/utils/mmgr/mcxt.c       | 25 ++++++++++++++++++++++++
src/backend/utils/mmgr/slab.c       | 10 ++++++++++
src/include/nodes/memnodes.h        |  1 +
src/include/utils/memutils.h        |  1 +
7 files changed, 121 insertions(+)



Message-ID: <E1iF7Lq-0008Sg-FC@gemulon.postgresql.org>
Permalink:  ../E1iF7Lq-0008Sg-FC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1iF7Lq-0008Sg-FC@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Add transparent block-level memory accounting
  In-Reply-To: <E1iF7Lq-0008Sg-FC@gemulon.postgresql.org>
  References: <E1iF7Lq-0008Sg-FC@gemulon.postgresql.org>

* 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