pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to calculate shared memory size
3+ messages / 3 participants
[nested] [flat]

* How to calculate shared memory size
@ 2020-09-15 14:12  Rébeli-Szabó Tamás <t@rblst.info>
  0 siblings, 1 reply; 3+ messages in thread

From: Rébeli-Szabó Tamás @ 2020-09-15 14:12 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hello all,

I want to do a proper calculation of the number of huge pages needed for 
PostgreSQL to start.

For that I need to know how much shared memory will be allocated at 
startup.

Looking at the shared memory calculation in the source (ipci.c), I can 
see that two terms stand out:

   size = add_size(size, BufferShmemSize()); ---> shared_buffers
   size = add_size(size, XLOGShmemSize()); --> 1/32 * shared_buffers, but 
max WAL segment size

However, if I only use those two terms (shared buffers + WAL segment 
size) for my calculation, the result will be off by a lot, especially 
with bigger shared buffers (e.g. 32 GB).

What are any other major terms (in the order of 10 megabytes or more) 
that I need to take into account to get a better result?

Regards,

tamas





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

* How to calculate shared memory size
@ 2020-09-15 14:15  Rébeli-Szabó Tamás <pub@rblst.info>
  0 siblings, 0 replies; 3+ messages in thread

From: Rébeli-Szabó Tamás @ 2020-09-15 14:15 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Hello all,

I want to do a proper calculation of the number of huge pages needed for 
PostgreSQL to start.

To do that, I need a good approximation of how much shared memory will 
be requested at server startup.

Looking at the shared memory calculation in the source (ipci.c), I can 
see that two terms stand out:

   size = add_size(size, BufferShmemSize()); ---> shared_buffers
   size = add_size(size, XLOGShmemSize()); --> 1/32 * shared_buffers, but 
max WAL segment size

If I use only those two terms ( shared buffers + WAL segment size) for 
my calculation, the result will be off by a lot, especially with bigger 
shared buffers (e.g. 32 GB).

What are any other major addends (in the order of 10 megabytes or more) 
that I need to take into account to get a better result?

Regards,

tamas






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

* Re: How to calculate shared memory size
@ 2020-09-15 14:49  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Rébeli-Szabó Tamás <t@rblst.info>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2020-09-15 14:49 UTC (permalink / raw)
  To: Rébeli-Szabó Tamás <t@rblst.info>; +Cc: pgsql-general@lists.postgresql.org

=?UTF-8?Q?R=C3=A9beli-Szab=C3=B3_Tam=C3=A1s?= <t@rblst.info> writes:
> I want to do a proper calculation of the number of huge pages needed for 
> PostgreSQL to start.
> For that I need to know how much shared memory will be allocated at 
> startup.

TBH, the only method that's not going to break over time is
"start the server with the parameters you want, and look to
see how big the shmem segment is".

We used to have an approximate formula in the documentation,
but we took it out years ago because it was constantly out of date.

			regards, tom lane





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


end of thread, other threads:[~2020-09-15 14:49 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 14:12 How to calculate shared memory size Rébeli-Szabó Tamás <t@rblst.info>
2020-09-15 14:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2020-09-15 14:15 How to calculate shared memory size Rébeli-Szabó Tamás <pub@rblst.info>

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