Re: Calculation of a shared memory

Lists: pgsql-hackers
From: "Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Calculation of a shared memory
Date: 2007-11-01 14:46:11
Message-ID: 068c01c81c95$f1cce120$c601a8c0@HP22720319231
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi.

I think that a calculation sheet will be made.
However, calculation does not suitable.:-(

It is this.(8.2.5 Default-FreeBSD)
--
max_locks_per_transaction 64
max_connections 40
max_prepared_transactions 5
shared_buffers 28MB
wal_buffers 64kB
max_fsm_relations 1000
max_fsm_pages 179200

inet% ipcs -b -m
Shared Memory:
T ID KEY MODE OWNER GROUP SEGSZ
m 917504 5432001 --rw------- saito wheel 32571392

40*(400+270*64)= 707200
5*(600+270*64)= 89400
28MB= 29360128
64kB= 65536
1000*70= 70000
179200*6= 1075200

Total :31367464
ipcs-m:32571392
-1203928 (difference is large: why?)

Table 16-2. Configuration parameters affecting PostgreSQL's shared memory usage
http://www.postgresql.org/docs/8.2/static/kernel-resources.html#SYSVIPC
It may be the bug of postgres or whether the document is wrong....
or My misapprehension.

Can someone see a near value?

Regards,
Hiroshi Saito


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Calculation of a shared memory
Date: 2007-11-01 17:48:13
Message-ID: 9045.1193939293@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp> writes:
> inet% ipcs -b -m
> Shared Memory:
> T ID KEY MODE OWNER GROUP SEGSZ
> m 917504 5432001 --rw------- saito wheel 32571392

> 40*(400+270*64)= 707200
> 5*(600+270*64)= 89400
> 28MB= 29360128
> 64kB= 65536
> 1000*70= 70000
> 179200*6= 1075200

> Total :31367464
> ipcs-m:32571392
> -1203928 (difference is large: why?)

Hmm, those numbers never got updated for 8.2. The per-backend
multiplier is particularly off, since it's not accounting for
the in-memory pg_stat_activity array (PgBackendStatus is 1208
bytes on my machine...) Also, you neglected to add the fixed space,
which was claimed to be 500K as of 8.1, but seems to have bloated
to about 700K in 8.2 and 770K in HEAD.

regards, tom lane


From: "Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Calculation of a shared memory
Date: 2007-11-02 01:23:39
Message-ID: 0b0b01c81cee$ff698a00$c601a8c0@HP22720319231
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi.

From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> "Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp> writes:
>> inet% ipcs -b -m
>> Shared Memory:
>> T ID KEY MODE OWNER GROUP SEGSZ
>> m 917504 5432001 --rw------- saito wheel 32571392
>
>> 40*(400+270*64)= 707200
>> 5*(600+270*64)= 89400
>> 28MB= 29360128
>> 64kB= 65536
>> 1000*70= 70000
>> 179200*6= 1075200
>
>> Total :31367464
>> ipcs-m:32571392
>> -1203928 (difference is large: why?)
>
> Hmm, those numbers never got updated for 8.2. The per-backend
> multiplier is particularly off, since it's not accounting for
> the in-memory pg_stat_activity array (PgBackendStatus is 1208
> bytes on my machine...) Also, you neglected to add the fixed space,
> which was claimed to be 500K as of 8.1, but seems to have bloated
> to about 700K in 8.2 and 770K in HEAD.

Sent: Friday, November 02, 2007 4:11 AM
Subject: [COMMITTERS] pgsql: Update shared-memory-size info for 8.2 branch.

Great, taken into consideration.

40*(1800+270*64)= 763200
5*(700+270*64)= 89900
28MB=29360128
64kB= 65536
1000*70= 70000
179200*6= 1075200
700kB= 716800

Total :32140764
ipcs-m:32571392
-430628

I think it is a permissible range. Thanks!

Regards,
Hiroshi Saito


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Calculation of a shared memory
Date: 2007-11-02 02:34:17
Message-ID: 19745.1193970857@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp> writes:
> 40*(1800+270*64)= 763200
> 5*(700+270*64)= 89900
> 28MB=29360128
> 64kB= 65536
> 1000*70= 70000
> 179200*6= 1075200
> 700kB= 716800

> Total :32140764
> ipcs-m:32571392
> -430628

> I think it is a permissible range. Thanks!

Most of the remaining discrepancy is because you did not account for the
per-shared-buffer management overhead. The table shows shared_buffers
as costing 8300 bytes each, not 8192.

regards, tom lane


From: "Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Calculation of a shared memory
Date: 2007-11-02 03:15:25
Message-ID: 0bc301c81cfe$9ce67900$c601a8c0@HP22720319231
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi.

Thanks!

From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
>> I think it is a permissible range. Thanks!
>
> Most of the remaining discrepancy is because you did not account for the
> per-shared-buffer management overhead. The table shows shared_buffers
> as costing 8300 bytes each, not 8192.

Oops, I did the misapprehension by the alteration of MB and kB.
This estimates the value secured more correctly.

40*(1800+270*64)= 763200
5*(700+270*64)= 89900
28MB*1024/8*8300= 29747200
64kB/8*8200= 65600
1000*70= 70000
179200*6= 1075200
700kB= 716800

Total :32527900
ipcs-m:32571392
-43492

Does this suit?

Regards,
Hiroshi Saito