From: | Takashi Horikawa <t-horikawa(at)aj(dot)jp(dot)nec(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Typo in bufmgr.c that result in waste of memory |
Date: | 2016-02-19 02:58:08 |
Message-ID: | 73FA3881462C614096F815F75628AFCD035A48C3@BPXM01GP.gisp.nec.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
I have just found a typo in the source code (not in a comment) of bufmgr.c
that result in waste of memory. It might be a 'bug' but it does not result
in any incorrect operation but just results in waste of a few memory
resource.
As sizeof(PrivateRefCountArray) found in InitBufferPoolAccess() is 64 and
sizeof(PrivateRefCountEntry) which should be used here is 8, this typo
produces 56 byte of unused memory area per one PrivateRefCount entry in the
hash table. I think this result in not only the waste of memory but also
reduces the cache hit ratio.
----
void
InitBufferPoolAccess(void)
{
HASHCTL hash_ctl;
memset(&PrivateRefCountArray, 0, sizeof(PrivateRefCountArray));
MemSet(&hash_ctl, 0, sizeof(hash_ctl));
hash_ctl.keysize = sizeof(int32);
X hash_ctl.entrysize = sizeof(PrivateRefCountArray);
O hash_ctl.entrysize = sizeof(PrivateRefCountEntry);
PrivateRefCountHash = hash_create("PrivateRefCount", 100, &hash_ctl,
HASH_ELEM | HASH_BLOBS);
}
----
Attached patch is for the latest development version at the git repository.
--
Takashi Horikawa
NEC Corporation
Knowledge Discovery Research Laboratories
Attachment | Content-Type | Size |
---|---|---|
correction_of_PrivateRefCount.patch | application/octet-stream | 538 bytes |
smime.p7s | application/pkcs7-signature | 6.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Chapman Flack | 2016-02-19 02:59:24 | Re: about google summer of code 2016 |
Previous Message | Peter Eisentraut | 2016-02-19 02:53:11 | Re: exposing pg_controldata and pg_config as functions |