Re: loading libraries on Postmaster startup

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: loading libraries on Postmaster startup
Date: 2003-02-13 04:29:39
Message-ID: 87k7g4ls5o.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Joe Conway <mail(at)joeconway(dot)com> writes:

> 2. It seems to me that other libraries such as those for PL/Tcl,
> PL/Perl, etc may have the same issue. Is there any merit in
> a GUC variable to allow libraries such as this to be loaded
> and initialized at postmaster start? I'll generalize this and
> send in a patch if there is interest.

A similar situation arises with mod_perl. Because perl is quite heavy-weight
and systems often need lots of packages with static data it's common to load a
startup.pl script that just loads lots of packages before the Apache server
forks. This reduces memory usage drastically.

The main gotcha is that you have to be careful about resources that you don't
want shared. The typical case is database handles which are sockets that
wouldn't be happy having two processes writing and reading on them.

At first blush it seemed unlikely you would have a database connection in an
embedded perl script. But then, hm, that would be a sly way of doing
interdatabase connections. In any case there are other situations where you
might want to have open file descriptors or sockets lying around.

So in short, not only is it useful, but it would be valuable to allow
mechanism to cause the language to load modules before forking. But there have
to be prominent caveats that no such shared packages should create resources
that can't be safely shared.

--
greg

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Curt Sampson 2003-02-13 04:32:15 Re: Changing the default configuration (was Re:
Previous Message Curt Sampson 2003-02-13 04:18:44 Re: [HACKERS] PostgreSQL Tuning Results

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-02-13 04:54:19 Re: pg_dump a specific schema
Previous Message Joe Conway 2003-02-13 04:15:24 loading libraries on Postmaster startup