dbTalk Databases Forums  

PL/Perl(U) internals curiosity

comp.databases.postgresql comp.databases.postgresql


Discuss PL/Perl(U) internals curiosity in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Anselmo Canfora
 
Posts: n/a

Default Re: PL/Perl(U) internals curiosity - 01-25-2010 , 06:48 AM






Il 25/01/2010 12.53, Laurenz Albe ha scritto:
Quote:
Anselmo Canfora wrote:
now I am wondering how PG manage the perl interpreter, I am not a C programmer, so I do not know a lot of things, however I would
like to understand something about the performance of perl stored procedures in PG, for example if they are managed in a similar
manner of apache/mod_perl, and if they are as fast as it in same tasks.

I don't know much about Perl and nothing about mod_perl, so I cannot
compare the two.
if you are curious here you can find an overview:
http://www.slideshare.net/gozer/from...odperl-20-fast

Quote:
It seems that the language handler loads the interpreter as shared library:

Yes, that is the way that you embed Perl into a C program.
See "man perlembed" for details.

And here:
http://www.postgresql.org/docs/curre...FUNC-C-DYNLOAD
it is stated that "Presently, unloads are disabled and will never occur, but this may change in the future", so is it correct to
think that the libperl.so* is kept in memory after the first invocation? If yes, is it the perl stored procedure AST compiled on
creation and then kept in memory after the first invocation?

As soon as PL/Perl has been loaded into the backend process, it
will remain there. So it remains loaded for the rest of the session.

There will be one Perl interpreter created per backend, or two
if you use both trusted and untrusted Perl in the same session.
so, one (trusted/untrusted) interpreter per connection?

Quote:
Stored procedures are realised as anonymous perl subroutines and
are cached (you can see that from the source; my Perl knowledge is
not sufficient to tell if that means that they are compiled only
once, but I'd guess so).
thank you very much for clarifications, thorough as usual

Quote:
To see the PL/Perl implementation, look here:
http://anoncvs.postgresql.org/cvsweb...h_tag=REL8_4_2
(it is currently being rewritten, so it's better to look at a stable branch).
I had a look on:
http://anoncvs.postgresql.org/cvsweb...h_tag=REL8_4_2

definitively not faintly understandable by mere humans like me

Quote:
I don't know what AST is, could you explain?
abstract syntax tree, it should be one of the steps for Perl compilation
into its internal representation called "optree", details should be
explained here:

http://www.perlfoundation.org/perl5/...gi?optree_guts

Quote:
Another question, there are not references to language handlers here?

root@pluto:/usr/lib/postgresql/8.3# ldd bin/post* | grep -i pl
root@pluto:/usr/lib/postgresql/8.3#

Yes, because they are not linked with the database server. They
are loaded at runtime as soon as they are needed.

Yours,
Laurenz Albe

Reply With Quote
  #12  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: PL/Perl(U) internals curiosity - 01-25-2010 , 08:46 AM






Anselmo Canfora wrote:
Quote:
There will be one Perl interpreter created per backend, or two
if you use both trusted and untrusted Perl in the same session.

so, one (trusted/untrusted) interpreter per connection?
Yes. Every connection has a backend process.

Yours,
Laurenz Albe

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.