Re: [HACKERS] loading libraries on Postmaster startup

From: Joe Conway <mail(at)joeconway(dot)com>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [HACKERS] loading libraries on Postmaster startup
Date: 2003-02-27 19:33:21
Message-ID: 3E5E6801.5040707@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Joe Conway wrote:
> Tom Lane wrote:
>> Joe Conway <mail(at)joeconway(dot)com> writes:
>>> In my testing with PL/R, it reduces the first call to a PL/R function
>>> (after connecting) from almost 2 seconds, down to about 8 ms.
>>
>> Hm, pretty significant. Can you measure any per-fork cost (ie, the loss
>> incurred by children that don't use PL/R)? Is there any measurable
>> benefit for our other PLs (plperl etc)?
>
> Here's what I got:
>
> 10000 connect/disconnect in tight loop
> ----------------------------------------------------------
> condition time top
> ----------------------------------------------------------
> with no preload 87 seconds ~10% CPU, ~2.2 MB
> with plr preload 133 seconds ~10% CPU, ~13 MB
> with plperl preload 92 seconds ~10% CPU, ~3.2 MB
> with pltcl preload 88 seconds ~10% CPU, ~2.3 MB
> with plpython preload 93 seconds ~10% CPU, ~2.3 MB
>
>
> 1000 connect/"select some_simple_func()"/disconnect in tight loop
> ------------------------------------------------------------------
> condition time top
> ------------------------------------------------------------------
> plr-func without preload 739 seconds ~60% CPU, ~13 MB
> plr-func with preload 26 seconds ~10% CPU, ~13 MB
> plperl-func without preload 46 seconds ~4% CPU, ~3.2 MB
> plperl-func with preload 33 seconds ~3% CPU, ~3.2 MB
> pltcl-func without preload 22 seconds ~5% CPU, ~2.3 MB
> pltcl-func with preload 17 seconds ~4% CPU, ~2.3 MB
> plpython-func without preload 33 seconds ~4% CPU, ~2.3 MB
> plpython-func with preload 31 seconds ~4% CPU, ~2.3 MB
>

Here's an updated copy of the patch. The original patch was failing due
to code drift in cvs.

Peter's suggestion (__attribute__((constructor))) is interesting, but it
appears to be a gcc specific extension, and hence non-portable.

I'd still like to see this applied if there are no other objections.
From the above info it is apparent that the benefit outweighs the cost
for plperl and pltcl (although not as significantly as for plr).

Joe

Attachment Content-Type Size
preload-libs.2.patch text/plain 7.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message mlw 2003-02-27 19:45:46 Re: analyze after a database restore?
Previous Message D'Arcy J.M. Cain 2003-02-27 18:58:47 Re: analyze after a database restore?

Browse pgsql-patches by date

  From Date Subject
Next Message Alvaro Herrera 2003-02-27 19:44:53 Re: Dump CLUSTER in pg_dump
Previous Message Jeroen T. Vermeulen 2003-02-27 18:07:50 psql patch (2)