Re: Patch for fixing a few memory leaks

From: Teodor Sigaev <teodor(at)stack(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for fixing a few memory leaks
Date: 2001-10-05 09:01:02
Message-ID: 3BBD76CE.9080308@stack.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>Tom, I want to notice that initGISTstate is called for every inserting
>>value (for each row). I think it's not good, because this function
>>called 'fmgr_info' 7 times. 'fmgr_info' call a
>>'load_external_function' with execution of sequence search on library
>>name. Any suggestion?
>>
>
> fmgr_info shouldn't be all that expensive; I'm not really inclined to
> worry about it. Do you have evidence to the contrary?

Tom, I make some test with this ugly patch which makes structure giststate
static (pls, don't commit this patch :) ).

Test:
1. install contrib/btree_gist
2. create 'sql.cmd' file contains:
DROP TABLE tbl;
BEGIN TRANSACTION;
CREATE TABLE tbl (v INT);
CREATE INDEX tblidx ON tbl USING GIST (v);
COPY tbl FROM '/tmp/data';
END TRANSACTION;
3. create /tmp/data with 10000 random values.

Result:
1. Original gist.c
% time psql wow < sql.cmd
psql wow < sql.cmd 0.00s user 0.02s system 0% cpu 7.170 total
2. Patched gist.c
% time psql wow < sql.cmd
psql wow < sql.cmd 0.02s user 0.00s system 2% cpu 0.699 total

We can see that calling fmgr_info for 70000 times may be very expensive.

--
Teodor Sigaev
teodor(at)stack(dot)net

Attachment Content-Type Size
ugly_patch.gz application/octet-stream 949 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas SB SD 2001-10-05 10:23:46 Re: Problem on AIX with current
Previous Message Tatsuo Ishii 2001-10-05 08:17:50 Re: Problem on AIX with current